问:如何用es6给数组去重?
答:
const set = new Set([1,2,3,4,4])
console.log([...set] )// [1,2,3,4]
console.log(Array.from(new Set([2,3,3,5,6]))); //[2,3,5,6]
问:const o = {
name : '1'
};
o.name = '2';
console.log(o); //这里打印什么?
问:如何用es6给数组去重?
答:
const set = new Set([1,2,3,4,4])
console.log([...set] )// [1,2,3,4]
console.log(Array.from(new Set([2,3,3,5,6]))); //[2,3,5,6]
问:const o = {
name : '1'
};
o.name = '2';
console.log(o); //这里打印什么?
本文标题:es6
本文链接:https://www.haomeiwen.com/subject/qrshnqtx.html
网友评论