THE WORLD'S LARGEST WEB DEVELOPER SITE
HTMLCSSJAVASCRIPTSQLPHPBOOTSTRAPJQUERYANGULARXML
 

JavaScript Array length Property

JavaScript Array Reference JavaScript Array Reference

Example

Return the length of an array:

var fruits = ["Banana", "Orange", "Apple", "Mango"];
fruits.length;

The result will be:

4
Try it yourself »

Definition and Usage

The length property sets or returns the number of elements in an array.


Browser Support

Property
length Yes Yes Yes Yes Yes

Syntax

Return the length of an array:

array.length

Set the length of an array:

array.length=number

Technical Details

Return Value: A Number, representing the number of elements in the array object
JavaScript Version: 1.1

JavaScript Array Reference JavaScript Array Reference