Javascript examples for Array:length Property
The length property sets or returns the number of elements in an array.
array.length
A Number, representing the number of elements in the array object
The following code shows how to return the length of an array:
<!DOCTYPE html> <html> <body> <button onclick="myFunction()">Test</button> <p id="demo"></p> <script> function myFunction() {//from w w w .j av a2 s.com var fruits = ["a","b","c","d","e"]; document.getElementById("demo").innerHTML = fruits.length; } </script> </body> </html>