1) To create new array which, you cannot iterate over, you can use array constructor:

Array(100) or new Array(100)


2) You can create new array, which can be iterated over like below:

a) All JavaScript versions

  • Array.apply: Array.apply(null, Array(100))

b) From ES6 JavaScript version

  • Destructuring operator: [...Array(100)]
  • Array.prototype.fill Array(100).fill(undefined)
  • Array.from Array.from({ length: 100 })

You can map over these arrays like below.

  • Array(4).fill(null).map((u, i) => i) [0, 1, 2, 3]

  • [...Array(4)].map((u, i) => i) [0, 1, 2, 3]

  • Array.apply(null, Array(4)).map((u, i) => i) [0, 1, 2, 3]

  • Array.from({ length: 4 }).map((u, i) => i) [0, 1, 2, 3]

Answer from stpoa on Stack Overflow
🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › JavaScript › Reference › Global_Objects › Array › Array
Array() constructor - JavaScript | MDN
Arrays can be created using a constructor with a single number parameter. An array is created with its length property set to that number, and the array elements are empty slots.
🌐
W3Schools
w3schools.com › jsref › jsref_array_new.asp
JavaScript new Array Method
new Array() called with no arguments, creates an empty array.
Discussions

How to initialize empty array of objects?
const arr: {name: string}[] = [] Maybe like this? More on reddit.com
🌐 r/typescript
14
18
May 27, 2021
Can you declare an array of unknown size in Javascript?
Simply create an empty array: ... Then you can add more elements dynamically by specifying any index (your array can even have "gaps" in it, an 'undefined' elements): ... The elements in an array may not be of the same type. As you can see, arrays in JavaScript are very flexible, so be careful ... More on teamtreehouse.com
🌐 teamtreehouse.com
3
October 24, 2014
Is there a way to guard against empty arrays?
For the first problem, you could turn on noUncheckedIndexAccess to avoid the runtime error. With that on, to declare a type for a non empty array, this might work: type People = [Person, ...Person[]] More on reddit.com
🌐 r/typescript
8
10
January 20, 2021
Official/Standard way for checking if array is empty
The code of Symfony itself does not use empty to check for empty arrays, and I think the opinion there is to avoid empty wherever possible. The $array === [] is correct, and don't have the weird behavior of empty, if $array is not an array. There is also the count($array) === 0 check, which I think is the best option, as it also works to check if array-like objects are empty, as long as they implement countable (like doctrines collections or ArrayObject). Empty() will always return false for these array-like objects, as the object is non-null. More on reddit.com
🌐 r/PHP
89
54
April 17, 2024
🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › JavaScript › Reference › Global_Objects › Array
Array - JavaScript | MDN
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.
🌐
Quora
quora.com › How-do-you-declare-an-empty-array-in-JavaScript
How to declare an empty array in JavaScript - Quora
Answer (1 of 19): You have two main ways to go: simple declaration with square brackets. const myArray = [] Or instantiation of the Array Object using the constructor method: const myArray = new Array() The trendy kids favor the first way, nowadays, with the empty square brackets, but if you h...
🌐
Sentry
sentry.io › sentry answers › javascript › how do i empty an array in javascript?
How do I Empty an Array in JavaScript? | Sentry
If you use this method to empty an array, bear in mind that the empty array is newly created. If another variable or property references the array, that variable or property will still point to the original array, as can be seen in the code example below: let arr = [1, 2, 3, 4, 5]; const arr2 = arr; arr = []; console.log(arr); // [] console.log(arr2); // [1, 2, 3, 4, 5] In JavaScript, objects are assigned and copied by reference, not by value.
Find elsewhere
🌐
Code Like A Girl
code.likeagirl.io › create-an-array-of-empty-arrays-7ec77edea546
How to create an array of empty arrays | by Ai-Lyn Tang | Code Like A Girl
June 25, 2019 - For two exercises in exercism.io (Matrix and Pascal’s Triangle), I have wanted to create an array of empty arrays. There are lots of ways to do this. My newbie mind defaults to forEach, for loops or while loops.
🌐
Sololearn
sololearn.com › en › Discuss › 1742669 › how-to-create-empty-array-in-javascript-and-insert-the-values-after
How to create empty array in JavaScript and insert the values after | Sololearn: Learn to code for FREE!
March 31, 2019 - javascriptarrays · 31st Mar 2019, ... · 31st Mar 2019, 7:54 AM · VEDANG · + 2 · You can create an empty array as var arrayName= []; and then to insert value in array you have many choices as 1....
🌐
Medium
medium.com › @ryan_forrester_ › empty-arrays-in-javascript-how-to-guide-f8643da412c2
Empty Arrays in JavaScript (How to Guide) | by ryan | Medium
October 30, 2024 - This guide will provide you with a detailed understanding of how to create, check, and manipulate empty arrays in JavaScript, including practical examples.
🌐
W3Schools
w3schools.com › js › js_arrays.asp
JavaScript Arrays
JavaScript has a built-in array constructor new Array(). But you can safely use [] instead. These two different statements both create a new empty array named points:
🌐
Altcademy
altcademy.com › blog › how-to-create-an-empty-array-in-javascript
How to create an empty array in JavaScript
August 24, 2023 - Here's how you can use it to create an empty array: ... It's important to note that while this method is perfectly valid, it's generally more common to use the square brackets method for its simplicity and readability. One interesting property of arrays in JavaScript is their length property.
🌐
Sololearn
sololearn.com › en › Discuss › 749562 › how-to-declare-an-empty-multidimensional-array-in-javascript
How to declare an empty multidimensional array in JavaScript? | Sololearn: Learn to code for FREE!
... let width=5; let height=5; let emptyArray = [...Array(height)].map(e => Array(width).fill(0)); alert(emptyArray ); ... To declare a Two Dimensional Array in Java, you can use either data_type[][] array_name = new data_type[SIZE][SIZE] ; (or) ...
🌐
Medium
medium.com › @wisecobbler › 4-ways-to-populate-an-array-in-javascript-836952aea79f
4 Ways to Populate an Array in JavaScript | by Sophia Shoemaker | Medium
December 5, 2018 - In this one-liner, the first argument of the from method is the object we want to create an array from. In this case, we are creating an empty object with a length property set to 10.
🌐
GeeksforGeeks
geeksforgeeks.org › javascript › create-an-array-of-given-size-in-javascript
Create an Array of Given Size in JavaScript - GeeksforGeeks
... // Given size const size = 5; // Initialize empty array const arr = []; // Iterate and add element in each iteration for (let i = 0; i < size; i++) { arr.push(i); } // Display output console.log("Array length", arr.length); console.log("Array ...
Published: July 23, 2025
🌐
Just Academy
justacademy.co › blog-detail › how-to-declare-empty-array-in-javascript
How to Declare Empty Array in JavaScript by Roshan Chaturvedi | JustAcademy
April 23, 2024 - In JavaScript, declaring an empty array is done simply by using empty square brackets `[]`. This is useful when you need to initialize a variable that will store a collection of elements but doesn't have any initial values yet.
🌐
GeeksforGeeks
geeksforgeeks.org › javascript › how-to-declare-two-dimensional-empty-array-in-javascript
How to Declare Two Dimensional Empty Array in JavaScript ? - GeeksforGeeks
July 23, 2025 - Example: In this example, the Empty2DArray function generates a 2D array with the specified number of rows (3) and columns (4) filled with null values. The arr1 is the resulting array.
🌐
Medium
allaboutcode.medium.com › javascript-how-to-create-and-fill-an-empty-array-with-a-given-size-ed6954355a5f
JavaScript — How to create and fill an empty array with a given size? - Marika Lam - Medium
November 17, 2022 - JavaScript — How to create and fill an empty array with a given size? Solution const arr = Array(5).fill(""); console.log(arr); //prints out ["","","","",""] console.log(arr[0]); //prints out "" 1) …
🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › JavaScript › Reference › Global_Objects › Array › fill
Array.prototype.fill() - JavaScript | MDN
Note: Using Array.prototype.fill() on an empty array (length = 0) would not modify it as the array has nothing to be modified. To use Array.prototype.fill() when declaring an array, make sure the array has non-zero length.