Javascript TUTORIAL for beginners

While Javascript does not require length to be expliciltly declared at the begining, you will need to find the length of the array at different times. Here is an example that prints the length of the array.


<script type="text/javascript">

var x = [0,1,2,3];
var y = ['toyota','honda','Audi'];

document.writeln('Length of Array x is ' + x.length + '<br />');
document.writeln('Length of Array y is ' + y.length + '<br />');


You may like to try this example online here .

There is nothing special here. The first array x has a 4 elements and the second array y has three elements

So it gives the output

In the next tutorial we will see some practical use of the length of the array element - to add element at the end of the array.