JavaScript lengthProperty
Examples
Return the number of elements in the 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
![]()
![]()
![]()
![]()
![]()
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, representing the number of elements in the array object. |
|---|---|
| JavaScript Version: | 1.1 |
JavaScript Array Object Other Extensions