Categories
JavaScript Answers

How to find the length or size of an array in JavaScript?

Spread the love

To find the length or size of an array in JavaScript, we use the length property.

For instance, we write

const arr = [];
testvar[1] = 2;
testvar[2] = 3;
console.log(arr.length);

to define the arr array.

And we set values for indexes 1 and 2.

Finally, we get the array size or length with the arr.length property.

By John Au-Yeung

Web developer specializing in React, Vue, and front end development.

Leave a Reply

Your email address will not be published.