Select Page

How to get the size of a array using JavaScript

To get the total size of the array elements within an JavaScript array the JavaScriptlength property can be used.


	var arr = new Array();
	arr[0] = 'val 1';
	arr[1] = 'val 2';
	alert(arr.length); //Will output 2

Leave a reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.