JavaScript Array length property
- Previous Page keys()
- Next Page lastIndexOf()
- Go to the Previous Level JavaScript Array Reference Manual
Definition and usage
length
Sets or returns the number of elements in the array.
Example
Return the length of the array:
var fruits = ["Banana", "Orange", "Apple", "Mango"]; fruits.length;
Syntax
Return the length of the array:
array.length
Set the length of the array:
array.length = number
Technical details
Return value: | A number that represents the number of elements in the array object. |
---|---|
JavaScript version: | ECMAScript 1 |
Browser support
All browsers fully support length
Property:
Chrome | IE | Edge | Firefox | Safari | Opera |
---|---|---|---|---|---|
Chrome | IE | Edge | Firefox | Safari | Opera |
Support | Support | Support | Support | Support | Support |
Related Pages
Tutorial:JavaScript Array
Tutorial:JavaScript Array Const
Tutorial:JavaScript Array Methods
Tutorial:JavaScript Sort Array
Tutorial:JavaScript Array Iteration
- Previous Page keys()
- Next Page lastIndexOf()
- Go to the Previous Level JavaScript Array Reference Manual