Add function getUnique for array.

This commit is contained in:
Slava Bacherikov committed 2012-01-22 10:23:44 +02:00
1 parent e68b0d170f
commit 5908f14cfc
1 file changed
+13 -1
+13 -1
View File
@@ -110,6 +110,18 @@ Array.prototype.swap = function (x,y) {
return this;
}
Array.prototype.getUnique = function(){
var u = {}, a = [];
for(var i = 0, l = this.length; i < l; ++i){
if(this[i] in u){
continue;
}
a.push(this[i]);
u[this[i]] = 1;
}
return a;
}
if(typeof(String.prototype.trim) === "undefined"){
String.prototype.trim = function() {
return String(this).replace(/^\s+|\s+$/g, '');
@@ -1018,7 +1030,7 @@ function metaDellManyTag(serial, len, key, func){
return false;
}
var r_ob = new Object();
r_ob[key] = answ_arr;
r_ob[key] = answ_arr.getUnique();
return r_ob;
} else {
return false;