The length property

The length property returns a number that tells you how many elements are in an array. It is useful when using loops to cycle through arrays. To use the length property you use the name of the array and then add the length property.

var StudentsClass = new Array(4);
document.write("The array has " + StudentsClass.length + " elements");

The output will be “The array has 4 elements”.

Note:
The index and input properties require a deep understanding of regular expressions. The explanation related to these two properties can be found on “Handling strings” on this website.

Leave a Reply