const hasFocus = (ele) => ele === document.activeElement;
const getSelectedText = () => window.getSelection().toString();
history.back(); // Or history.go(-1);
const cookies = document.cookie.split(';').map((item) => item.split('=')).reduce((acc, [k, v]) => (acc[k.trim().replace('"', '')] = v) && acc, {});
// `a` 和 `b` 都是数组 const isEqual = (a, b) => JSON.stringify(a) === JSON.stringify(b); // 或者 const isEqual = (a, b) => a.length === b.length && a.every((v, i) => v === b[i]); // 事例 isEqual([1, 2, 3], [1, 2, 3]); // true isEqual([1, 2, 3], [1, '2', 3]); // false
微信公众号链接