Recently, I began delving into the Rapid JavaScript Training course by Mark Zamoyta on PluralSight and encountered a fascinating concept. Through two examples, he demonstrated an intriguing concept that I've been attempting to comprehend.
I'm puzzled about how the length of entries is captured after creating an array using the new Array()
method, especially since it resulted in an empty array []
. In theory, shouldn't it return -1
since it's empty like this []
?
var entries = [1,2,3,4,5];
entries.length
=> 5
entries
=> [ 1, 2, 3, 4, 5 ]
var entries = new Array(5);
entries.length
=> 5
entries
=> []