数组去重(高效率,ES6才支持)

mac2022-06-30  30

//数组去重 function distinct(arr) {   let result = [];   let obj = {};   for(let i of arr) {     if(!obj[i]) {       result.push(i);       obj[i] = 1;     }   }   return result }

转载于:https://www.cnblogs.com/fei-le/p/11383281.html

最新回复(0)