length
Array
instance property
JS Home <<
JS Reference <<
Array <<
length
Description
Syntax
Signature | Description |
---|---|
anArray.length | Returns a positive integer holding the number of elements within an array between 1 and 4,294,967,295. |
Parameters
None.
Examples
The code below displays Array
objects and their lengths.
// Create an array with three elements.
var anArray = new Array('one', 'two', 'three');
alert(anArray + ' - ' + anArray.length);
// Create an array with a length of 10.
var newArrayWithLength = new Array(10);
alert(newArrayWithLength + ' - ' + newArrayWithLength.length);
Related Tutorials
JavaScript Intermediate Tutorials - Lesson 1 - Arrays