how to Initialize a Javascript Array with non-zero index
javascript
Solution
Something like:
var a = new Array(100).concat([4321]);
Problem
I'm passing an array to a function and I'm curious if there is a quick way to use the json style array initializer to pass an anonymous array: e.g.: ``` myfunction([1,2,3,4]); ``` Is there some special syntax in javascript that would allow one to initialize the array with non-zero index? for example, instead of ``` myfunction([,,,,4321]); //array[4] == 4321 here ``` but if you have an array that has the first 100 positions undefined, you would have to have 100 commas. [,,....,4321] basically looking for a short form for: ``` var a = new Array(); a[100] = 4321; ``` that you can use as a function parameter.