ES6
海到无边天作岸山登绝顶我为峰
这个作者很懒,什么都没留下…
展开
-
ES6-Object.assign()
Object.addign(target, source1, source2) 该方法用于对象的合并,将源对象(source)的所有可枚举属性,复制到目标对象。source1,source2可选,如果只有source,则此方法返回target本身。 const target = { a: 1, b: 1 }; const source1 = { b: 2, c: 2 }; const source2 = { c: 3 }; Object.assign(target, source1, source2).原创 2020-09-30 01:10:07 · 94 阅读 · 0 评论 -
es6 数组元素去重的,通过Set来解决
数组–》Set–>去重–》数组 function dedupe(array) { return Array.from(new Set(array)); } dedupe([1, 1, 2, 3]) // [1, 2, 3]: Set 保证了数据不重复, let set = new Set([1,1,2,32]); Array.from(set); 将set转为数组原创 2020-08-18 12:23:39 · 199 阅读 · 0 评论