如何利用es6去重

如下是三种方法从数组里去重,而且返回惟一的值。我最喜欢的方式是使用Set,由于它是最短最简单的。es6 const array = [5, 2, 4, 5, 3]; console.log([...new Set(array)]) console.log(array.filter((item, index) => array.indexOf(item) === index)) console.lo
相关文章
相关标签/搜索