Let’s learn about some more properties of arrays and play around with arrays in JavaScript.
array.length is an interesting property that helps you in cases like loops where the length of an array is required. Length of an array implies the number of elements inside an array.
Imagine that you have an array of 1000 numbers and you need to add 500 more numbers into that array. These numbers would be added one after the other, at the beginning of the array. Wouldn't it be messy if you had to keep changing the indices of all the 1000 elements every time you add a new number? Perhaps we can use some inbuilt functions for simplifying this problem. Well, JavaScript provides you functions to do just that. Let us see how to use them.
The functions you just learnt are as follows:
Apart from these properties, there are some more properties that are quite helpful. These properties are
Isn’t this quite interesting that different data types can be combined in JavaScript in an array? This makes arrays in JavaScript more versatile and powerful than arrays in other languages.