What’s the difference between empty items in a JavaScript array and undefined? [duplicate]

When I create an empty array, I’ll get ’empty items’ which seem to
behave differently from undefined. Can someone explain what is the
difference?

That’s because Array(10) doesn’t populate the array. But it just set the length property to 10 .So, the array created using Array constructor is simply an object with a length property, but with no items populated.

Leave a Comment