js数组
小白_起航
UI+web开发
展开
-
JS如何区分对象和数组
判断JS如何区分对象和数组使用typeof是不行的,直接上方法代码: 一、直接使用内置方法isArray来判断,当然,只能判断是否是数组,对象还需要另外再判断 const a = [1, 2, 3, 4]; const b = {"name": "小白-起航"}; console.log(Array.isArray(a)) //true console.log(Array.isArray(b)) //false 二、使用constructor来判断 `const a = [2, 4, 3]; cons原创 2021-03-24 10:39:35 · 3045 阅读 · 1 评论 -
js-时间格式转换
时间处理对于前端来说有点烦但是又不能避免,这个方法挺好用,在此记录一下,谢谢博主,下面有链接 function rTime(date) { var json_date = new Date(date).toJSON(); return new Date(new Date(json_date) + 8 * 3600 * 1000).toISOString().replace(/T/g, ' ').replace(/\.[\d]{3}Z/, '') } let date = rTime('20转载 2020-12-11 16:50:53 · 107 阅读 · 0 评论 -
记录一次数组相同筛选
记录一次数组相同筛选 subList(){ let data = [{ time:"2020-03-14", name:"maomao" }, { time:"2020-03-14", name:"maomao" }, { time:"2020-03-15", name:"maomao" }, { time:"2020-03-15", name:"原创 2020-12-10 14:19:43 · 69 阅读 · 0 评论