JavaScript Array Properties

About This Index
This page is the JavaScript Array Properties index for the tutorial track. The property you will use every day is length. Elements are not named fields; you read them with an index or a method.
Learn what an Array is on /js/array. Functions such as push() and map() live on the Array Methods index.
colors.length is a number. colors.push("gold") is a method, so it needs parentheses. colors.length() throws.
How to Read an Array Property
Properties are values. No parentheses:
const colors = ["red", "green", "blue"];
colors.length; // 3
colors.constructor === Array; // true
Array.prototype.push; // the method function
Array.length; // 1
Array.name; // "Array" JavaScript Array Properties Table
Properties on an array value and on the Array function (5 entries). length counts items. Array.length is the constructor’s argument count.
On an array value
2 propertiesRead these on an array you created with [] or new Array(). Items are not properties named 0 and 1 in the tutorial sense — you read them with indexes and methods.
| Property | Description | Guide |
|---|---|---|
length | The count of elements. colors.length is 3 for three items. Assigning a smaller length drops items from the end. | On this page |
constructor | The function that created the array. For an array literal, constructor is Array. | On this page |
On the Array function
3 propertiesRead these on Array itself. They describe the constructor, not the items in a list.
| Property | Description | Guide |
|---|---|---|
Array.prototype | Shared object where push(), map(), filter(), and the other array methods live. | Open |
Array.length | Array.length is 1. That is how many arguments the constructor is specified to accept, not the number of items in a list. | On this page |
Array.name | Array.name is "Array", the name of the constructor function. | On this page |
Frequently Asked Questions
Change the list with methods
length counts items. push(), map(), and filter() do the work.
8 people found this page helpful
