Code Highlights logo

Learn

Arrays

The .length property

The .length property provides the length or size of an array, which represents the number of elements it contains. This property is read-only, meaning that you can't assign a value to it directly.

Syntax:

1array.length

Example:

1const fruits = ["apple", "banana", "orange"];
2console.log(fruits.length); // Output: 3

In the above example, the array fruits contains three elements, so the value of fruits.length is 3.


Instructions

1.

Print the length of the myArray using the .length property to the console.

Sign up to start coding

Already have an account?

Sign In

Course content