Example 1 – Array Constructor
// Declare an array (using the array constructor) var arlene1 = new Array(); var arlene2 = new Array("First element", "Second", "Last");
Example 2 – Literal notatoin
// Declare an array (using literal notation) var arlene1 = ; var arlene2 = ["First element", "Second", "Last"];
Example 3 – Implicit Declaration
To avoid script errors, you should get into the habit of initializing an array when you declare it, like so:
// Declare an empty array using literal notation: var arlene = ; // The variable now contains an array of length zero
After checking my code on jslint.com I found out it says declaring an array with an array constructor is seen as bad practise! It suggests using literal notation.