How to create an array with out specifying any length?
What are dense arrays and how can we use them?
In many a cases we will not want to create the array with a fixed size or length. In such cases we can create an array with out passing length. This array will dynamically set its value as and when a new variable or entry is added.Syntax: var araay = new Array();
Now we can assign value at any position in this array as it has no length limit. We can test this by using the attribute "length".
varname = "testing array";
As we have assigned a value at 6th position the length of array will now be 7.
var araay = new Array();
araay = "testing array";
document.write("Size of dynamic array is - "+araay.length);
Dense array is nothing different in functionality from a normal array. The only difference is that the values are assigned to the array at the time of initialization of the array.
E.g: var arraa = new Array("index 0","index 1","index 2");
var arraa = new Array("array test 1","array test 2");
document.write("Result from dense array is - "+arraa);
In the next chapter we will look into the predefined methods of Array object ..