4 ms·
I agree that var a = new Array(1,2,3,4,5); is an old construct and should be replaced by var a = [1,2,3,4,5]; but the form var a = new Array(10); can be very
by bdfh42 14y ago
I agree that
var a = new Array(1,2,3,4,5);
is an old construct and should be replaced by
var a = [1,2,3,4,5];
but the form
var a = new Array(10);
can be very effective when you need an array with n elements and you are not in a position to .push() new ones in - you just need those elements to be there.
No confusion here - just lots of helpful language features.