Why can't I print the value of indexOf in this way?

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

.
Mar.01,2021

you might as well add [0]
var arr= [] .slice.call (arguments [0]) to your arguments;
try

again.
Menu