function unique(arr) { var result = [], hash = {}; for (var i = 0, elem; (elem = arr[i]) != null; i++) { if (!hash[elem]) { result.push(elem); hash[elem] = true; } } return result; }
function unique(arr, attribute){
var result = [], hash = {};
for (var i=0; i<arr.length; i++) {
var elem = arr[i][attribute];
if (!hash[elem]) {
result.push(arr[i]);
hash[elem] = true;
}
}
return result;
}