Js determines whether there are placeholder elements in the array

var arry = [1br 2];
arry [2] / / undefined
is there a way like indexOf to return the index value of the placeholder?

Apr.27,2021

var arry = [1,2,,4,5];
for(var i=0;i<arry.length;iPP){
    if(arry[i]){
        console.log("success");
    }else {
        console.log(i);
    }
}

the place where success is printed can also be left empty


arr.findIndex (I = > i=undefined)
only returns the index, found for the first time. If there are more than one, you have to traverse

yourself.
Menu