Array properties

Array length

Try the free JavaScript compiler

The length is an integer in the range zero through 2^32−1. It tracks the index boundary, not the number of existing elements. Reducing writable length deletes higher indexed own properties subject to configurability.

Formal Syntax & Structure

javascript syntaxjavascript
items.length

Return Value

Number

Current index boundary; writable on ordinary arrays.

Working Example

Example Snippetjavascript
const a=[7]; a.length=4;console.log(a.length,3 in a);
JavaScript Reference