The length property of an Array instance is a data property whose value is always numerically greater than the name of every configurable own property whose name is an array index.
Typically, the value is number of elements of array. (provided you didn't set length, and didn't use
delete operator to delete array elements, etc.)
[see JS: Delete operator]
const ar = [3,4]; console.log ( ar.length ); // 2
Array length can be set. If you set it, the array will be lengthened (becomes sparse array) or shortened (tail elements removed).
[see JS: Sparse Array]
[see JS: Understand JS Array]
- JS: Array Basics
- JS: Understand JS Array
- JS: Create Array
- JS: Sparse Array
- JS: Array-Like Object
- JS: Array How-To
Ask me question on patreon