随笔分类 -  es6

摘要:ES6中Set是一个新的数据结构,类似数组,本身是一个构造函数。它的成员都是唯一的,没有重复值,此项功能可以给数组去重! const s=new Set(); var arr1=[2,3,4,5,2,2,3]; arr1.forEach(i=> { s.add(i); }); s.add(6).ad 阅读全文
posted @ 2022-01-18 11:14 密蒙 阅读(189) 评论(0) 推荐(0) 编辑
摘要:const days = endDate.getTime() - startDate.getTime() < 0 ? 0 : Number(new BigNumber(new BigNumber(endDate.getTime() - startDate.getTime()).dividedBy(2 阅读全文
posted @ 2021-12-24 16:28 密蒙 阅读(44) 评论(0) 推荐(0) 编辑
摘要:const array1 = [8, 35, 12, 25, 66]; array1.unshift(100); console.log('向数组的最前端添加一个或多个值,添加后array1的结果:' + array1); //向数组的最前端添加一个或多个值,添加后array1的结果:100,8,3 阅读全文
posted @ 2021-12-24 13:54 密蒙 阅读(20) 评论(0) 推荐(0) 编辑
摘要:const array1 = [10, 11, 12]; console.log('获取数组的和:' + array1.reduce((a, b) => a + b)) //结果:获取数组的和:33 console.log('获取数据的最大值:' + Math.max(...array1)); // 阅读全文
posted @ 2021-12-23 16:49 密蒙 阅读(22) 评论(0) 推荐(0) 编辑
摘要:import * as _ from 'lodash'; const arr= _.unionBy([2.1,1.2,2.9,1.8,3.5,9.6],Math.floor); console.log('arr:'+arr); 返回结果:arr:2.1,1.2,3.5,9.6 unionBy用来对数 阅读全文
posted @ 2021-03-05 11:07 密蒙 阅读(240) 评论(0) 推荐(0) 编辑

点击右上角即可分享
微信分享提示