In your first example, you are making a blank array, same as doing var x = []. The 2nd example makes an array of size 3 (with all elements undefined). The 3rd and 4th examples are the same, they both make arrays with those elements.

Be careful when using new Array().

var x = new Array(10); // array of size 10, all elements undefined
var y = new Array(10, 5); // array of size 2: [10, 5]

The preferred way is using the [] syntax.

var x = []; // array of size 0
var y = [10] // array of size 1: [1]

var z = []; // array of size 0
z[2] = 12;  // z is now size 3: [undefined, undefined, 12]
Answer from gen_Eric on Stack Overflow
🌐
W3Schools
w3schools.com › js › js_arrays.asp
JavaScript Arrays
Using an array literal is the easiest way to create a JavaScript Array. ... It is a common practice to declare arrays with the const keyword.
🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › JavaScript › Reference › Global_Objects › Array
Array - JavaScript - MDN Web Docs
July 28, 2026 - Array elements are object properties in the same way that toString is a property (to be specific, however, toString() is a method). Nevertheless, trying to access an element of an array as follows throws a syntax error because the property name is not valid: ... JavaScript syntax requires properties beginning with a digit to be accessed using bracket notation instead of dot notation.
🌐
GeeksforGeeks
geeksforgeeks.org › javascript › how-to-declare-an-array-in-javascript
How to Declare an Array in JavaScript? - GeeksforGeeks
July 23, 2025 - Array constructor allows dynamically creating array and setting their initial state. It allows passing in elements as arguments to populate the array. If no argument is passed, an empty array is created.
🌐
Freewebdesigntutorials
freewebdesigntutorials.com › javaScriptTutorials › jsArrayObject › declareAnArray.php
Declare an Array in JavaScript
You will learn to declare arrays both using the JavaScript array constructor [new Array()], and by using the array literal notation. Both declaration methods allow you to simultaneously initialize array elements, as well as array length in the case of the constructor.
🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › JavaScript › Reference › Global_Objects › Array › Array
Array() constructor - JavaScript - MDN Web Docs
new Array() new Array(element1) new Array(element1, element2) new Array(element1, element2, /* …, */ elementN) new Array(arrayLength) Array() Array(element1) Array(element1, element2) Array(element1, element2, /* …, */ elementN) Array(arrayLength)
🌐
EDUCBA
educba.com › home › software development › software development tutorials › javascript tutorial › javascript declare array
JavaScript Declare Array | Declaration of an Array in JavaScript - Examples
March 28, 2023 - If we call the constructor with two or more than two arguments, these arguments initialize the array elements. Time complexity increases due to insertion and deletion operations, wastage of memory as the length of the array is fixed, i.e once the array is declared, array size cannot be modified. This is a guide to JavaScript Declare Array.
Address: Unit no. 202, Jay Antariksh Bldg, Makwana Road, Marol, Andheri (East),, 400059, Mumbai
Find elsewhere
🌐
TutorialsTeacher
tutorialsteacher.com › javascript › javascript-array
JavaScript Arrays: Create, Access, Add & Remove Elements
We have learned that a variable can hold only one value. We cannot assign multiple values to a single variable. JavaScript array is a special type of variable, which can store multiple values using a special syntax. The following declares an array with five numeric values.
🌐
JavaScript in Plain English
javascript.plainenglish.io › chapter-55-everything-you-need-to-know-about-arrays-in-javascript-declaration-initialization-and-210940cd8412
Chapter 55:Everything You Need to Know About Arrays in JavaScript: Declaration, Initialization, and Beyond 🧠 | by Aryan kumar | JavaScript in Plain English
October 18, 2024 - Arrays are an essential data structure in JavaScript that allow you to store multiple values in an ordered collection. Use square brackets [] to declare arrays or the Array constructor (though square brackets are recommended).
🌐
TOOLSQA
toolsqa.com › javascript › array-in-javascript
Array in JavaScript and Common Operations on Arrays with examples
As discussed above, JavaScript array is an object that represents a collection of similar type of elements. Now to initialize that array object, JavaScript provides three ways: First, Array declaration and initialization using JavaScript Array Literals.
🌐
GeeksforGeeks
geeksforgeeks.org › javascript › javascript-arrays
JavaScript Arrays - GeeksforGeeks
We can increase and decrease the array length using the JavaScript length property.
Published: 3 weeks ago
🌐
Altcademy
altcademy.com › blog › how-to-declare-an-array-in-javascript
How to declare an array in JavaScript - Altcademy.com
June 9, 2023 - The most straightforward way to declare an array is using square brackets []. You can create an empty array or an array with initial elements.
🌐
Altcademy
altcademy.com › blog › how-to-declare-array-in-javascript
How to declare array in JavaScript - Altcademy.com
June 9, 2023 - The array literal syntax is the more commonly used and recommended way to declare arrays in JavaScript.
🌐
Yaldex
yaldex.com › javascript_net › html › 9bd1c820-1027-48f4-b708-3d798440fe72.htm
Array Declaration
To declare a new JScript Array object, you can use the new operator with the Array constructor. Since you can dynamically add members to a JScript array, you do not need to specify an initial size for the array.
🌐
JavaScript.info
javascript.info › tutorial › the javascript language › data types
Arrays
An array is a special kind of object. The square brackets used to access a property arr[0] actually come from the object syntax. That’s essentially the same as obj[key], where arr is the object, while numbers are used as keys.
🌐
GeeksforGeeks
geeksforgeeks.org › javascript › how-to-initialize-an-array-in-javascript
How to initialize an array in JavaScript ? - GeeksforGeeks
July 23, 2025 - Initializing an array in JavaScript involves creating a variable and assigning it an array literal. The array items are enclosed in square bracket with comma-separated elements.
🌐
Code Institute
codeinstitute.net › blog › javascript › javascript arrays
Javascript Arrays: A Guide - Code Institute Global
December 20, 2022 - Element numbers in JavaScript range from 0 to n-1. The ‘n’ stands for the JavaScript array’s overall element count. Two-dimensional arrays are used to express the array’s elements in the structure of rows and columns, which are then used to represent what is called a matrix. Two-dimensional arrays utilise two subscripts to declare the array’s elements.
🌐
GeeksforGeeks
geeksforgeeks.org › javascript › whats-the-difference-between-array-and-while-declaring-a-javascript-array
Difference Between “Array()” and “[]” JS Array Declaration - GeeksforGeeks
July 12, 2025 - The "Array()" and "[]" are used to declare new array JavaScript. The Array() is the constructor method of array and the [] syntax is knowns as array literal. The [] array literal is a simple and mostly preferred way to declare an array while ...