JS 數組去重

Array.prototype.unique3 = function(){ //數組去重
var res = [];
var json = {};
for(var i = 0; i < this.length; i++){
if(!json[this[i]]){
res.push(this[i]);
json[this[i]] = 1;
}
}
return res;
}json

$scope.selectedShops=$scope.selectedShops.unique3();數組

js 數組遍歷this

for(j in $scope.aggShops){
if ($scope.aggShops[j].siteId != "ALL") {
$scope.siteIds.push($scope.aggShops[j].siteId);
};
}prototype

2222222222222it

$scope.aggShops.forEach(function(e){
if (e.siteId != "ALL") {
$scope.siteIds.push(e.siteId);
};
console.log(e);
})io

相關文章
相關標籤/搜索