1 var users = [ 2 {id: 1, name: 'a'}, 3 {id: 2, name: 'a'}, 4 {id: 3, name: 'b'}, 5 {id: 4, name: 'b'} 6 ] 7 8 Array.prototype.unique = function() { 9 var obj = {}, arr = []; 10 var context = this, name; 11 for(var i = 0; i < context.length; i++) { 12 name = context[i].name; 13 if(!obj[name]) { 14 obj[name] = 1; 15 arr.push(name); 16 } 17 } 18 return arr; 19 } 20 21 users.unique();