THE WORLD'S LARGEST WEB DEVELOPER SITE

JavaScript Array length Property

❮ JavaScript Array Reference

Example

Return the length of an array:

var fruits = ["Banana", "Orange", "Apple", "Mango"];
fruits.length;
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: ECMAScript 1

❮ JavaScript Array Reference