The length
method is used to get the length of an array.
array.length
The length
method attaches to the right side of an array with the .
operator. The length method is used to get the size of an array.
const fruits = ['apple', 'banana', 'orange'];
console.log(fruits.length); // Prints: 3
There are three items in the array so the output of the fruits.length
is 3.