Video Lesson

Lesson Notes

Understanding JavaScript Array Properties

Arrays in JavaScript come with built-in properties, like length, to help you inspect and manage them.

Getting the Length

Use the .length property to find how many elements are in an array:

1const myList = [0, null, true, false, { name: "Alice" }]; 2console.log(`The length of the list is: ${myList.length}`); 3// Outputs: The length of the list is: 5

If you remove elements:

1myList.pop(); 2myList.pop(); 3console.log(`The length of the list is: ${myList.length}`); 4// Outputs: The length of the list is: 3

Accessing Properties Directly

You don’t need a variable—access properties right on the array literal:

1console.log([1, 2, 3, "yes"].length); // 4

Key Points

  • .length reflects the highest index + 1.
  • It updates automatically when you add or remove elements.

AI Assistant

Sign In Required

Sign in and subscribe to use the AI assistant for instant help with your lessons.

Sign In

Exploring Array Properties

In this lesson, you will learn about JavaScript array properties like `.length`, learning how to easily determine the number of elements in an array.

2m 19s

Course Content

0 of 32 lessons completed
6. Promises, Async and Await
0 of 0 completed
7. The DOM
0 of 0 completed