If I want to make an array that is say of length 3 using bracket notation, should I just write: var foo = [,,];
I was more used to writing: var foo = new Array(3);
I noticed that if I removed one , that my code still worked which is surprising because I am accessing all 3 elements after assigning them. How is it that it would still work?
Arraywith specific lengthn, you can useArray(n).join().split(','). So, if you need anArraycontaining 100 empty elements:Array(100).join().split(',').new Array(100)?Array(100)you can't use methods likemap. E.g.Array(100).join().split(',').map(function(){return 1;})returns anArraycontaining 100 elements with value 1,Array(10).map(function(){return 1;})anArraycontaining 100 elements with valueundefined