Curriculum
Course: JavaScript Basic
Login

Curriculum

JavaScript Basic

JSHome

0/216
Text lesson

Access the Full Array

In JavaScript, the entire array can be accessed by referencing its name.

Example

const cars = [“Saab”“Volvo”“BMW”];
document.getElementById(“demo”).innerHTML = cars;

Arrays are Objects

Arrays are a unique category of objects. When assessed with the typeof operator in JavaScript, arrays return “object”.

However, it’s more accurate to characterize JavaScript arrays simply as arrays.

Arrays employ numerical indices to retrieve their “elements”. In this instance, person[0] retrieves “John”.

Array:

const person = [“John”“Doe”46];

Objects utilize names to access their “members”. In this instance, person.firstName retrieves “John”.

Object:

const person = {firstName:“John”, lastName:“Doe”, age:46};