JavaScript Array length Property

JavaScript Array Reference JavaScript Array Reference

Example

Return the length of an array:

fruits.length;

The result could 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

SHARE THIS PAGE

COLOR PICKER

colorpicker





Search w3schools.com:

Translate w3schools.com: