How to get length of array in JavaScript | JavaScript Array Length

The array length properties in JavaScript that return or sets the number of elements in a given array.
The JavaScript Array Length property of an array can be returned such as:

<!DOCTYPE html>
<html>
<body>
<p>To create an array click on the button, then display its length.</p>
<button onclick="myFunction()">Click here</button>
<p id="demo"></p>
<script>
function myFunction() {
  var cars = ["Acura", "Audi", "Bentley", "BMW", "Bugatti"];
  document.getElementById("demo").innerHTML = cars.length;
}
</script>
</body>
</html>