多应用+插件架构,代码干净,二开方便,首家独创一键云编译技术,文档视频完善,免费商用码云13.8K 广告
## 请分别用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); ~~~