➢An array is a special variable, which can hold more than one value.
➢Using an array literal is the easiest way to create a JavaScript Array.
EXAMPLE:
const cars = ["Saab", "Volvo", "BMW"];
EXAMPLE:
const cars = []
cars[0]= "Saab";
cars[1]= "Volvo";
cars[2]= "BMW";
➢Using the JavaScript Keyword new
EXAMPLE:
const cars = new Array("Saab", "Volvo", "BMW");
Accessing Array Elements
➢ou access an array element by referring to the index number.
EXAMPLE:
const cars = ["Saab", "Volvo", "BMW"];
let car = cars[0];
➢Changing an Array Element
EXAMPLE:
const cars = ["Saab", "Volvo", "BMW"];
let car = cars[0] = "Opel" ;
➢Access the Full Array
EXAMPLE:
const cars = ["Saab", "Volvo", "BMW"];
document.getElementById("demo").innerHTML = cars;
➢The length property of an array returns the length of an array (the number of array elements).
EXAMPLE:
const cars = ["Saab", "Volvo", "BMW"];
let length = cars.length;