Javascript Array pset(p)
Array.prototype.pset = function(p) { // create a set such that each element in the array is an object with properties var uniq = [];/* ww w . ja va2s . c o m*/ var a = []; var t = Object(this); for (var i = 0; i < t.length; i++) { var prop = t[i][p]; if (uniq.indexOf(prop) == -1) { uniq.push(t[i][p]); a.push(t[i]); } else { continue; } } return a; }