What is an array:-
- As we all know that an array is a variable that can hold more than one value or multiple values at a time and the index of an array starts with 0.
- An array is declared with the keyword const.
Example of an array:-
const companies = ['TCS','IBM','HCL','INFOSYS'];
Length Property of the array:-
The length property counts the number of values in an array.
For eg:- If we want to find the length of the above array then it can be obtained as shown below
let company length = companies.length;
To store the length of the above array, you can declare another variable with the let keyword that holds the result which means the number of values of the above array.
let variable name = array name[array name.length - 1];
Now, get the last of the element of the companies array as shown below
let lastelementofcompany = companies[companies.length - 1];
Conclusion:- I hope this tutorial will help you to understand the concept. If there is any doubt then please leave a comment below.