Array.prototype.unip = function () {
var temp = {},
len = this.length;
for (var i = 0; i < len; i++) {
if (typeof temp[this[i]] == "undefined") {
temp[this[i]] = 1;
}
}
this.length = 0;
len = 0;
for (var i in temp) {
this[len++] = i;
}
return this;
}
var arr = [1,2,3,4,4,4,4,4,4,5,5,6,6,7,7,5];
arr.unip();
alert(arr);
var temp = {},
len = this.length;
for (var i = 0; i < len; i++) {
if (typeof temp[this[i]] == "undefined") {
temp[this[i]] = 1;
}
}
this.length = 0;
len = 0;
for (var i in temp) {
this[len++] = i;
}
return this;
}
var arr = [1,2,3,4,4,4,4,4,4,5,5,6,6,7,7,5];
arr.unip();
alert(arr);