生成随机ID
// 生成长度为11的随机字母数字字符串Math.random().toString(36).substring(2);
获取URL的查询参数
// 获取URL的查询参数q={};location.search.replace(/([^?&=]+)=([^&]+)/g,(_,k,v)=>q[k]=v);q;
数组混淆
// 随机更改数组元素顺序,混淆数组(arr) => arr.slice().sort(() => Math.random() - 0.5)
生成随机十六进制代码(生成随机颜色)
'#' + Math.floor(Math.random() * 0xffffff).toString(16).padEnd(6, '0');
去除空格
const trim = (str) => {return str.replace(/^\s*|\s*$/g, '')}
