- ✕This summary was generated using AI based on multiple online sources. To view the original source information, use the "Learn more" links.
In JavaScript, arrays are used to store multiple values in a single variable. They can be created using various methods depending on the use case.
Example: Using Array Literal
The simplest way to create an array is by using square brackets [].
const fruits = ["Apple", "Banana", "Cherry"];console.log(fruits); // Output: ["Apple", "Banana", "Cherry"]Copied!✕CopyUsing the Array Constructor
You can create an array using the Array constructor. If a single numeric argument is passed, it creates an array with that length filled with empty slots.
const arr = new Array(5);console.log(arr); // Output: [ <5 empty items> ]Copied!✕CopyUsing Array.from()
This method creates a new array from an iterable or with a specified length and mapping function.
const arr = Array.from({ length: 5 }, (_, index) => index);console.log(arr); // Output: [0, 1, 2, 3, 4]Copied!✕CopyUsing Array.apply()
You can use Array.apply() along with .map() to create arrays with specific values.
JavaScript Arrays - W3Schools
Array - JavaScript | MDN
Feb 24, 2026 · This example shows three ways to create new array: first using array literal notation, then using the Array() constructor, and finally using String.prototype.split() to build the array from a string.
JavaScript Arrays - How to Create an Array in JavaScript
May 16, 2022 · In this article, I will show you 3 ways you can create an array using JavaScript. I will also show you how to create an array from a string using the …
JavaScript Arrays - GeeksforGeeks
Oct 3, 2025 · In JavaScript, an array is an ordered list of values. Each value, known as an element, is assigned a numeric position in the array called its index. The …
JavaScript Array
This tutorial introduces you to JavaScript array type and demonstrates the unique characteristics of JavaScript arrays via examples.
Searches you might like
Arrays - The Modern JavaScript Tutorial
Nov 20, 2025 · The call to new Array(number) creates an array with the given length, but without elements. The length property is the array length or, to be precise, its …
Creating and Manipulating Arrays in JavaScript - Tutorial Republic
In this tutorial you will learn how to create and manipulate arrays in JavaScript. Arrays are complex variables that allow us to store more than one value or a group of values under a single variable name.
JavaScript Array (with Examples) - Programiz
In JavaScript, an array is an object that can store multiple values at once. In this tutorial, you will learn about JavaScript arrays with the help of examples.
JavaScript Arrays: Create, Access, Add & Remove Elements
Learn what is an array and how to create, add, remove elements from an array in JavaScript.
JavaScript | Arrays | Codecademy
Mar 20, 2024 · In JavaScript, an Array is a list of ordered, stored data. It can hold items that are of any data type (e.g. string, boolean, number, etc.) and it can hold …