Course Content
Introduction to JavaScript
The array is the most useful data structure.
Note
Data Structure is a specialized format for working with a data set (data organization).
Array is an item collection where items are literals.
Creating
To create an array you need to use []
:
It's the array without elements (empty array). To create an array with elements, you should put elements into []
and separate them with commas (,
):
Note
There should be no comma after the last element of the array.
You can print the array by console.log()
:
Indexes
Every element in the array has a unique index:

Note
Indexes start from 0. The first element is placed with the index 0, the second element is placed with the index 1, etc.
To calculate the index of an element, you can use the formula "N - 1" (where N is the number of the element).
You have access to the array data by index. You can retrieve an element from the array simply by writing its index in square brackets ([index]
) after the array name:
Arrays in JS can work with different data types: number, string, boolean, etc.
Length
The length
is a property. The length
returns an array length:
Note
Property and Method concepts is used in Object-Oriented Programming (OOP). This will be described in another course.
Methods are called like functions using parentheses
()
, while properties provide values like variables.
Which brackets are used to create an array?
Select the correct answer
Retrieve second element from the array:
Select the correct answer
How to get the length of the array?
Select the correct answer
Section 2.
Chapter 6