标签:let func cti pre log nbsp return 去重 blog
用es6实现:
let arr = [1,2,3,4,5,6,6,3,1]; console.log(new Set(arr));// [1,2,3,4,5,6]
用es5实现:
arr.filter(function(ele,index,array){ return index === array.indexOf(ele); });
// [1,2,3,4,5,6]
标签:let func cti pre log nbsp return 去重 blog
原文地址:http://www.cnblogs.com/zh2289633869/p/7327955.html