length  Array  instance propertyS2C Home  « Globals « Array « length

Description

Array element length.

Syntax

Signature Description
anArray.lengthReturns 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);

Press the button below to action the above code:


Related Tutorials

JavaScript Intermediate Tutorials - Lesson 1 - Arrays



go to home page Homepage go to top of page Top