Javascript does include a mechanism for declaring the length of your array, for example:
var foo = new Array(3);
alert(foo.length);
But since arrays are dynamic in javascript, there is no reason for this, you do not need to manually allocate your arrays. In the above example, an array of fixed length is not created, it simply initializes it with three undefined elements.
// Edit: I am either reading your question incorrectly, or you changed it, sorry, I do not think that this is what you asked for.
source
share