JS: Array.prototype

By Xah Lee. Date: . Last updated: .

Array.prototype is the value of the property key "prototype" of the function Array.

[see JS: Array Object]

console.log( Array.hasOwnProperty ( "prototype" ) ); // true

Type of Array.prototype is object.

[see JS: Data Types]

// type of Array.prototype
console.log ( typeof Array.prototype === "object" ); // true
console.log ( Object.prototype.toString.call( Array.prototype ) === "[object Array]" ) // true
console.log ( Array.isArray ( Array.prototype ) ) // true

Parent of Array.prototype is Object.prototype.

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

[see JS: Prototype and Inheritance]

Array.prototype is the parent of all array objects.

console.log (
Object.getPrototypeOf ( [3,4,5] ) === Array.prototype
); // true

The purpose of Array.prototype object is to provides methods and properties useful for all array objects

[see JS: Understand JS Array]

Properties

Value Properties

  1. Array.prototype.length
  2. Array.prototype.constructor

Function Properties

modify elements

  1. Array.prototype.pop
  2. Array.prototype.push
  3. Array.prototype.shift
  4. Array.prototype.unshift
  5. Array.prototype.splice
  6. Array.prototype.fill ES2015
  7. Array.prototype.copyWithin ES2015

concat and subarray

  1. Array.prototype.concat
  2. Array.prototype.slice

map

  1. Array.prototype.map
  2. Array.prototype.forEach
  3. Array.prototype.filter

sort, reverse

  1. Array.prototype.sort
  2. Array.prototype.reverse

find element

  1. Array.prototype.indexOf
  2. Array.prototype.lastIndexOf
  3. Array.prototype.find ES2015
  4. Array.prototype.findIndex ES2015
  5. Array.prototype.includes ES2016

true false on all elements

  1. Array.prototype.some
  2. Array.prototype.every

reduce to single value

  1. Array.prototype.reduce
  2. Array.prototype.reduceRight

convert to string

  1. Array.prototype.join
  2. Array.prototype.toString
  3. Array.prototype.toLocaleString

ES2015

  1. Array.prototype.entries ES2015
  2. Array.prototype.keys ES2015
  3. Array.prototype.values ES2015
  4. Array.prototype [ Symbol.iterator ] ES2015
  5. Array.prototype [ Symbol.unscopables ] ES2015

When you see function of this form:

Array.prototype.f

you can call it by one of the following way:

[see JS: Function Call, Apply, Bind]


Array.prototype.length

[see JS: Array.prototype.length]

Array.prototype.constructor

[see JS: Array.prototype.constructor]


Array.prototype.push

[see JS: Array.prototype.push]

Array.prototype.pop

[see JS: Array.prototype.pop]

Array.prototype.unshift

[see JS: Array.prototype.unshift]

Array.prototype.shift

[see JS: Array.prototype.shift]

Array.prototype.splice

[see JS: Array.prototype.splice]

Array.prototype.fill

[see JS: Array.prototype.fill]

Array.prototype.copyWithin

[see JS: Array.prototype.copyWithin]


Array.prototype.concat

[see JS: Array.prototype.concat]

Array.prototype.slice

[see JS: Array.prototype.slice]


Array.prototype.map

[see JS: Array.prototype.map]

Array.prototype.forEach

[see JS: Array.prototype.forEach]

Array.prototype.filter

[see JS: Array.prototype.filter]


Array.prototype.sort

[see JS: Array.prototype.sort]

Array.prototype.reverse

[see JS: Array.prototype.reverse]


Array.prototype.indexOf

[see JS: Array.prototype.indexOf]

Array.prototype.lastIndexOf

[see JS: Array.prototype.lastIndexOf]

Array.prototype.find

[see JS: Array.prototype.find]

Array.prototype.findIndex

[see JS: Array.prototype.findIndex]

Array.prototype.includes

[see JS: Array.prototype.includes]


Array.prototype.every

[see JS: Array.prototype.every]

Array.prototype.some

[see JS: Array.prototype.some]


Array.prototype.reduce

[see JS: Array.prototype.reduce]

Array.prototype.reduceRight

[see JS: Array.prototype.reduceRight]


Array.prototype.toString

[see JS: Array.prototype.toString]

Array.prototype.toLocalString

myArray.toLocalString ()

ECMAScript® 2016 Language Specification#sec-array.prototype.tolocalestring

Array.prototype.join

[see JS: Array.prototype.join]


Array.prototype.entries

ECMAScript® 2016 Language Specification#sec-array.prototype.entries

Array.prototype.keys

ECMAScript® 2016 Language Specification#sec-array.prototype.keys

Array.prototype.values

Array.prototype[Symbol.iterator]

Array.prototype[Symbol.unscopables]

Reference

ECMAScript® 2016 Language Specification#sec-array.prototype

Array Topic

  1. JS: Array Basics
  2. JS: Understand JS Array
  3. JS: Create Array
  4. JS: Sparse Array
  5. JS: Array-Like Object
  6. JS: Array How-To

  1. JS: Array Object
  2. JS: Array.prototype

JS Object Reference

  1. Global
  2. Object
  3. Array
  4. Function
  5. String
  6. RegExp
  7. Date
  8. Set
  9. Map
  10. JSON
  11. Math
  12. Reflect
  13. Number
  14. Boolean
  15. Symbol
Liket it? Put $5 at patreon.

Or, Buy JavaScript in Depth