I see the example that creates an array using
var array = new Array(5);
but also I see something like this
arrayObj[0] = "index zero";
arrayObj[10] = "index ten";
I think the above code creates an object with two field name 0 and 10 like below? Is that correct?
arrayobj {
0: "index zero"
10: "index ten"
}
any different in this two way to create array using new Array() and new Object ?
var arrayObj = []; arrayObj[0] = "index zero"; arrayObj[10] = "index ten"; console.log(arrayObj)/var arrayObj = {}; arrayObj[0] = "index zero"; arrayObj[10] = "index ten"; console.log(arrayObj)new Array(5);- this will create a sparse array with onlylengthproperty and no array elements.