![](https://img-blog.csdnimg.cn/20201014180756757.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
常用工具函数
累了你就写会代码吧
越自律,越自由
展开
-
前端常用工具函数2
获取一个随机布尔值 (true/false)const randomBoolean = () => Math.random() >= 0.5;console.log(randomBoolean());// Result: a 50/50 change on returning true of false检查日期是否为工作日const isWeekday = (date) => date.getDay() % 6 !== 0;console.log(isWeekday(.转载 2021-07-07 16:00:11 · 66 阅读 · 0 评论 -
VS Code 搜索替换中正则匹配规则说明
示例:json匹配规则(\S+)\s(\S+)\s(\S+) {"store":"$1","provice":"$2","city”:"$3"},常用匹配符号含义:注意事项:在VSCode中使用时,要先把通配符开关打开(开关是查找输入框右边的".*"符号)转义字符 匹配内容\t tab\r 回车符号\r\n 换行符号\n\uxxxx 匹配Unicode编码为xxx的字符,如\u0020匹配空格,这个符号可以用来帮助匹配中文,后面说\ 特原创 2020-12-05 15:41:16 · 3096 阅读 · 0 评论 -
前端常用工具函数
日期格式化时间格式化timestampToTime(timestamp) { var date = new Date(timestamp);//时间戳为10位需*1000,时间戳为13位的话不需乘1000 var Y = date.getFullYear(); var M = (date.getMonth() + 1 < 10 ? '0' + (date`在这里插入代码片`.getMonth() + 1) : date.getMonth() + 1); var原创 2020-07-28 14:01:59 · 337 阅读 · 0 评论