Other way to create array part 2


Other Ways to Create Arrays
40
2/2












Creating Arrays
JavaScript arrays are dynamic, so you can declare an array and not pass any arguments with the Array() constructor. You can then add the elements dynamically.
You can add as many elements as you need to.
Array Literal
For greater simplicity, readability, and execution speed, you can also declare arrays using the array literal syntax.
This results in the same array as the one created with the new Array() syntax.
You can access and modify the elements of the array using the index number, as you did before.
The array literal syntax is the recommended way to declare arrays.
Comments
Post a Comment