Back to Course

Introduction to JavaScript

0% Complete
0/0 Steps
  1. JavaScript: Basics
    9Topics
    |
    10 Quizzes
  2. JavaScript: Variables
    9Topics
    |
    10 Quizzes
  3. JavaScript: Conditional Statements
    10Topics
    |
    11 Quizzes
  4. JavaScript: Functions
    10Topics
    |
    11 Quizzes
  5. JavaScript: Scope
    6Topics
    |
    7 Quizzes
  6. JavaScript: Arrays
    11Topics
    |
    12 Quizzes
  7. JavaScript: Loops
    8Topics
    |
    9 Quizzes
  8. JavaScript: High Order Functions
    3Topics
    |
    4 Quizzes
  9. JavaScript: Iterators
    6Topics
    |
    6 Quizzes
Lesson 6, Topic 6
In Progress

JavaScript: .length property

Yasin Cakal 12 Nov 2021
Lesson Progress
0% Complete

The .length property of an array is one of its built-in properties, and it returns the number of items in the array. We use the.length property in the same way we use it with strings. Consider the following example:

const signalLight = ['Red', 'Green', 'Yellow'];
console.log(signalLight.length);

//Output: 3

In the above example, we log signalLight.length to the console by performing the following steps:

  1. To access the .length property of the signalLight array, we use dot notation, chaining a period with the property name to the array.
  2. The length of signalLight is then printed to the console.
  3. Because signalLight has three elements, only 3 will be logged to the console.

The .length property can be used to determine the number of elements in an array.

Responses

Leave a Reply

%d bloggers like this: