// merge but don't remove duplicationsconstmerge= (a, b) =>a.concat(b);
orconstmerge= (a, b) => [...a, ...b];
// merge with remove duplicationsconstmerge= (a, b) => [...newSet(a.concat(b))];
orconstmerge= (a, b) => [...newSet([...a, ...b])];
1.
2.
3.
4.
5.
6.
7.
8.
10. 滚动到页面顶部
有很多方法可以将页面滚动到顶部。
constgoToTop= () =>window.scrollTo(0,0, "smooth");
orconstscrollToTop= (element) =>element.scrollIntoView({behavior: "smooth", block: "start"});
// scroll to bottom of the pageconstscrollToBottom= () =>window.scrollTo(0, document.body.scrollHeight);
1.
2.
3.
4.
5.
11.复制到剪贴板
在 Web 应用程序中,复制到剪贴板因其对用户的便利性而迅速普及。
const copyToClipboard = text (navigator.clipboard?.writeText ?? Promise.reject)(text);