JavaScript Array length
Example
Return the length of an array:
const fruits = ["Banana", "Orange", "Apple", "Mango"];
fruits.length // Returns 4
Try it Yourself »
Definition and Usage
The length property sets or returns the number of elements in an array.
Browser Support
length is fully supported in all browsers:
| Chrome | IE | Edge | Firefox | Safari | Opera |
| Yes | 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 |

