array.length
array.length = number
<html>
<head>
<title> array.length </title>
</head>
<body>
<h3> Here, we are finding the length of an array. </h3>
<script>
var arr = new Array( 100, 200, 300, 400, 500, 600 );
document.write(" The elements of array are: " + arr);
document.write(" <br>The length of the array is: " + arr.length);
</script>
</body>
</html>
<html>
<head>
<title> array.length </title>
</head>
<body>
<h3> Here, we are setting the length of an array. </h3>
<script>
var arr = [100, 200];
document.write(" Before setting the length, the array elements are: " + arr);
arr.length = 9;
document.write("<br><br> After setting the length, the array elements are: " + arr);
// It will print [ 1, 2, <7 undefined items> ]
arr[2] = 300;
arr[3] = 400;
arr[4] = 500;
arr[5] = 600;
document.write("<br><br> After inserting some array elements: " + arr);
</script>
</body>
</html>
<html>
<head>
<title> array.length </title>
</head>
<body>
<h3> There are five array elements but the index of the array is non numeric. </h3>
<script>
var arr = new Array();
arr['a'] = 100;
arr['b'] = 200;
arr['c'] = 300;
arr['d'] = 400;
arr['e'] = 500;
document.write("The length of array is: " + arr.length);
</script>
</body>
</html>
<html>
<head>
<title> array.length </title>
</head>
<body>
<script>
var str = "Welcome to the bianchenghao6.com";
var arr = new Array();
arr = str.split(" ");
document.write(" The given string is: " + str);
document.write("<br><br> Number Of Words: "+ arr.length);
document.write("<br><br> Number of characters in the string: " + str.length);
</script>
</body>
</html>