合规国际互联网加速 OSASE为企业客户提供高速稳定SD-WAN国际加速解决方案。 广告
## 请分别用ES5和ES6实现数组去重 ### IndexOf ~~~ var newArray = []; for (var i = 0, len = array.length; i < len; i++) { if (newArray.indexOf(array[i]) === -1) newArray.push(array[i]); } console.log(newArray) ~~~ ### includes ~~~ var newArray = array.reduce(function (result, current) { if (!result.includes(current)) result.push(current); return result; }, []); console.log(newArray) ~~~ ### From ~~~ var newArray = Array.from(new Set(array)); console.log(newArray); ~~~