Open links in new tab
  1. Copilot Search Branding
    • Work Report
    • Email
    • Rewrite
    • Speech
    • Title Generator
    • Smart Reply
    • Poem
    • Essay
    • Joke
    • Instagram Post
    • X Post
    • Facebook Post
    • Story
    • Cover Letter
    • Resume
    • Job Description
    • Recommendation Letter
    • Resignation Letter
    • Invitation Letter
    • Greeting Message
    • Try more templates
  1. 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!

    Using 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!

    Using 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!

    Using Array.apply()

    You can use Array.apply() along with .map() to create arrays with specific values.

    Feedback
  2. JavaScript Arrays - W3Schools

    If you have a list of items (a list of car names, for example), storing the cars in single variables could look like this: However, what if you want to loop through the cars and fi…
    Creating An Array

    Using an array literal is the easiest way to create a JavaScript Array. Syntax: Spaces and line breaks are not important. A declaration can span multiple lines: You can also create an array, and then provide the elements:

    Arrays Are Objects

    Arrays are a special type of objects. The typeofoperator in JavaScript returns "object" for arrays. But, JavaScript arrays are best described as arrays. Arrays use numbers to access its "elements". In this example, personreturns John: Objects us…

    Array Elements Can Be Objects

    JavaScript variables can be objects. Arrays are special kinds of objects. Because of this, you can have variables of different types in the same Array. You can have objects in an Array. You can have functions in an Array. You can have arrays in an Array:

    Array Properties and Methods

    The real strength of JavaScript arrays are the built-in array properties and methods: Array methods are covered in the next chapters.

  3. 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.

  4. 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 …

  5. 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 …

  6. JavaScript Array

    This tutorial introduces you to JavaScript array type and demonstrates the unique characteristics of JavaScript arrays via examples.

  7. 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 …

  8. 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.

  9. 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.

  10. JavaScript Arrays: Create, Access, Add & Remove Elements

    Learn what is an array and how to create, add, remove elements from an array in JavaScript.

  11. 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 …