length  Array  instance property JS Home  <<  JS Reference  <<  Array  <<  length

Description

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

JavaScript Basics

JavaScript Basics

JavaScript Intermediate

JavaScript Intermediate

JavaScript Advanced

JavaScript Advanced

JavaScript Reference

JavaScript Entities

Globals

Array

Class Properties
prototype
Instance Properties
constructor
length
Class Methods
None.
Instance Methods Getters
concat()
join()
slice()
toString()
Instance Methods Setters
pop()
push()
reverse()
shift()
sort()
splice()
unshift()

Statements

Operators