×

JavaScript Arrays

JavaScript Arrays

An array is a special JavaScript object used to store multiple values in a single variable. Arrays allow storing values of different data types and provide built-in methods for efficient data manipulation.

Beginner 30 Minutes Monopoly IT Solutions Updated 2026-08-07
JavaScript class training banner
5.0
5.0
4.6
Overview

What you'll cover

Learning objectives

  • Understand JavaScript Arrays
  • Create arrays using literals
  • Create arrays using constructors
  • Access array elements
  • Understand array length
  • Iterate arrays
  • Create 2D arrays
  • Store mixed data types

Prerequisites

  • Variables
  • Data Types
  • Loops
  • Functions
  • Basic JavaScript

Related topics

  • Array Methods
  • Objects
  • Loops
  • Functions
  • JSON
Theory

Concept breakdown

What is an Array?

An array stores multiple values in a single variable.

Array Index

Array indexing starts from 0.

Array Literal

The preferred way to create arrays.

Array Constructor

Arrays can also be created using new Array().

Two Dimensional Arrays

Arrays can contain other arrays.

Syntax
Hands-on example

JavaScript Arrays

Console Output
> "[10,20,30,"Sathesh",null,true,40]"
> "object"
> "7"
> "10"
> "20"
> "30"
> "Sathesh"
> "null"
> "true"
> "40"
> "[[10,20,30],[40,50,60],[70,80,90]]"
> "[10,20]"
> "3x3 empty array"
Walkthrough

Step by step

  1. 1

    Create Array

    Create using literal.

  2. 2

    Display

    Print the array.

  3. 3

    Length

    Use length property.

  4. 4

    Loop

    Iterate using for loop.

  5. 5

    2D Array

    Create nested arrays.

  6. 6

    Constructor

    Create using Array constructor.

Summary

Key takeaways

Key points

  • Zero-based indexing
  • Dynamic size
  • Mixed data types supported
  • Literal notation preferred
  • Supports multidimensional arrays

Advantages

  • Easy
  • Dynamic
  • Fast access
  • Mixed types
  • Built-in methods

Disadvantages

  • Mixed types reduce readability
  • Large arrays use memory
Real-world use

Student Marks

Store student marks in an array.

Interview prep

Frequently asked questions

A collection of values stored in one variable.

0

Literal and Constructor.

Yes.

Total elements.

Yes.

Array Literal.

array[0].

length-1

Built-in JavaScript Array object.

Test yourself

Quick MCQ practice

1. Index starts from?

2. Preferred creation?

3. Property for size?

4. 2D array contains?

5. Array literal uses?

Apply it

Practice on your own

Coding exercise

Employee Array

Create and display an employee array.

Assignment

  1. Create an array
  2. Display using loop
  3. Create 2D array
  4. Use constructor
  5. Print length

Tags

#javascript#arrays#beginner#array literal#array constructor

getintouch

Book for Live Demo!