JavaScript length Property
Example
Return the number of elements in an array:
fruits.length;
The result could be
4
Try it »
Definition and Usage
The length property can set or return the number of elements in an array.
Browser support





All major browsers support the length property.
Syntax
Set the number of elements in an array:
array
.length=
number
Return the length of an array:
array
.length
Technical Details
| Return Value: | A number indicating the number of elements in the array. |
|---|---|
| JavaScript version: | 1.1 |
JavaScript Array object