JavaScript Tutorial

javascript array length

TGTeam GyaniPanditJuly 21, 20221 min read

Javascript Array Length

By length of the array, we just mean the number of elements in the array. So, for getting the length of the array, you can use the length property. Remember that the length of the array simply means the number of elements in the array.

Let’s have a look at the below program, where we are trying to get the length of the array.

javascript array length 1Lets now have a look at the output for the above program –

javascript array length 2

As you can see that there are 6 elements in the array, so the length of the array is 6. Notice how are we using the length property. We are writing the variable name, followed by the dot, and then we are writing length, and this is how we are getting the length of the array. We can make use of the length property, whenever we need the length of the array.

Turn reading into skillsCertificate courses in AI, Data Science and programming.
Explore Courses