JavaScript lengthProperty

Array Object 参考手册JavaScript Array Object

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

Internet ExplorerFirefoxOperaGoogle ChromeSafari

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


Array Object 参考手册JavaScript Array Object Other Extensions