JS: Array.prototype

By Xah Lee. Date: . Last updated: .

What is Array.prototype

Array.prototype is the value of the property key "prototype" of the function Array. 〔see Array Object

Array.hasOwnProperty ( "prototype" )

Type

Type of Array.prototype is Object .

typeof Array.prototype === "object"

Array.prototype is a true array. Meaning, you can push elements to it, and with a magical length property.

console.log(Array.isArray(Array.prototype));

console.log(Array.prototype.length === 0);

Array.prototype.push("x");

console.log(Array.prototype[0] === "x");

console.log(Array.prototype.length === 1);

Parent

Parent of Array.prototype is Object.prototype .

// parent of Array.prototype
console.log(
 Reflect.getPrototypeOf ( Array.prototype ) === Object.prototype
);

Purpose

Purpose of Array.prototype is to provide methods and properties useful for all array objects

Array.prototype is the parent of all array objects.

Properties

Value Properties

Function Properties

Get Set an element by index

Add, Remove

Add or Remove Subarray

Sort, Reverse

Map, Iteration, Reduce

Find element

Convert to string

Array Iterator

Other

JavaScript. Array