var arr = ['1','2','3','13','4','2','0','7','6','3','2'];Array.prototype.unique = function() { var temArr = new Array(); for(var i in this) { if(typeo ...
var arr = ['1','2','3','13','4','2','0','7','6','3','2'];
Array.prototype.unique = function() {
var temArr = new Array();
for(var i in this) {
if(typeof this[i] !== 'function' && temArr.join(',').indexOf(this[i]) < 0) {
temArr.push(this[i]);
}
}
return temArr;
}
function unique1(arr) {
return Array.from(new Set(arr));
}
console.info(arr.unique());
console.info(unique1(arr));
>>>["1", "2", "3", "13", "4", "0", "7", "6"]
>>>["1", "2", "3", "13", "4", "0", "7", "6"]