function uniq() {
var arr=[].slice.call(arguments);
arr.forEach(function(a){
console.log(a); //a
console.log(arr.indexOf(a)); //index
if(arr.indexOf(a)!=arr.lastIndexOf(a)){
arr=arr.splice(arr.indexOf(a),1);
}
});
return arr;
}
uniq([false, true, undefined, null, NaN, 0, 1, {}, {}, "a", "a", NaN]);
I have tried to use the for loop, but I still haven"t printed out all the index values. I can only print the index:0, of false all the time. Is this related to the elements in the array? but I have tried to print arr= [false, true, undefined, null, NaN, 0,1, {}, {}, "averse," indexing, NaN] and manually typing arr.indexOf (true) can be printed
.