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; };
原文地址:https://www.cnblogs.com/mnxxz/p/9875318.html
时间: 2024-10-11 16:53:55