Skip to content

Instantly share code, notes, and snippets.

@jakeauyeung
Created December 11, 2014 06:33
Show Gist options
  • Save jakeauyeung/7040c5a7797c4362d2c5 to your computer and use it in GitHub Desktop.
Save jakeauyeung/7040c5a7797c4362d2c5 to your computer and use it in GitHub Desktop.
数组去重
var _user = [
{'id': '11', 'name': 'fame'},
{'id': '11'},
{'id': '22'}
],
newArr = []
for(var i = 0,len = _user.length; i < len; i++){
for(var j = i + 1; j < len; j++){
if(_user[i]['id'] == _user[j]['id']){
j = ++i
}
}
newArr.push(_user[i])
}
console.log(newArr);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment