JavaScript Array length property

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;

Try it yourself

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