Categories
JavaScript Answers

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

Spread the love

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

For instance, we write

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

to create the array arr.

Then we get its size with arr.length.

By John Au-Yeung

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

Leave a Reply

Your email address will not be published. Required fields are marked *