Creating Arrays
There are several ways to create an array. The first case is using the literal syntax. The second is calling the JavaScript Array object constructor.
An odd quirk of the JavaScript language that can cause an unintentional error is the following:
JavaScript also allows you to omit the new keyword in the Array constructor syntax.
In practice, it is much more common to use the literal syntax, except for special cases where you need to create an array of an initial size but not set the values, or specify an initial value for all the elements in a large array.
Last updated
Was this helpful?