DEV Community

Discussion on: Kyle Simpson proved I STILL don't know JavaScript (arrays)

Collapse
 
paceaux profile image
Paceaux

I went ahead and updated my test gist with an if in test to see what it did.

const slotted = [,,'one'];
let i = 0;

while (i < slotted.length) {
 if (i++ in slotted) {
  console.log(`${i - 1} is in the array`);
 }
}

it, too, will inform us that only an index of 2 exists. This I think further confirms that these items in the array are not "hidden properties" at all.