标签:== ++ javascrip style === val function pre res
function unique(objArr) { var result = {}; var proObj = objArr[0]; for(var pro in proObj){ var hash = []; for(var i = 0; i < objArr.length; i++){ var obj = objArr[i]; for(var pros in obj){ if(pros === pro){ var val = obj[pros]; if(!hash[val]){ var valueObj = {}; valueObj.lable = val; valueObj.value = val; hash.push(valueObj); hash[val] = true; } } } } result[pro] = hash; } return result; };
原生JavaScript对象数组去重,重构为对象{pro1:[hash], pro02: [hash]}
标签:== ++ javascrip style === val function pre res
原文地址:https://www.cnblogs.com/mnxxz/p/9875318.html