JavaScript: Array.prototype

By Xah Lee. Date: . Last updated: .

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

〔►see JavaScript: Array Object

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

Type of Array.prototype is object.

〔►see JavaScript: 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 JavaScript: 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 JavaScript: 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 JavaScript: Function Call, Apply, Bind


Array.prototype.length

〔►see JavaScript: Array.prototype.length

Array.prototype.constructor

〔►see JavaScript: Array.prototype.constructor


Array.prototype.push

〔►see JavaScript: Array.prototype.push

Array.prototype.pop

〔►see JavaScript: Array.prototype.pop

Array.prototype.unshift

〔►see JavaScript: Array.prototype.unshift

Array.prototype.shift

〔►see JavaScript: Array.prototype.shift

Array.prototype.splice

〔►see JavaScript: Array.prototype.splice

Array.prototype.fill

〔►see JavaScript: Array.prototype.fill

Array.prototype.copyWithin

〔►see JavaScript: Array.prototype.copyWithin


Array.prototype.concat

〔►see JavaScript: Array.prototype.concat

Array.prototype.slice

〔►see JavaScript: Array.prototype.slice


Array.prototype.map

〔►see JavaScript: Array.prototype.map

Array.prototype.forEach

〔►see JavaScript: Array.prototype.forEach

Array.prototype.filter

〔►see JavaScript: Array.prototype.filter


Array.prototype.sort

〔►see JavaScript: Array.prototype.sort

Array.prototype.reverse

〔►see JavaScript: Array.prototype.reverse


Array.prototype.indexOf

〔►see JavaScript: Array.prototype.indexOf

Array.prototype.lastIndexOf

〔►see JavaScript: Array.prototype.lastIndexOf

Array.prototype.find

〔►see JavaScript: Array.prototype.find

Array.prototype.findIndex

〔►see JavaScript: Array.prototype.findIndex

Array.prototype.includes

〔►see JavaScript: Array.prototype.includes


Array.prototype.every

〔►see JavaScript: Array.prototype.every

Array.prototype.some

〔►see JavaScript: Array.prototype.some


Array.prototype.reduce

〔►see JavaScript: Array.prototype.reduce

Array.prototype.reduceRight

〔►see JavaScript: Array.prototype.reduceRight


Array.prototype.toString

〔►see JavaScript: Array.prototype.toString

Array.prototype.toLocalString

myArray.toLocalString ()

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

Array.prototype.join

〔►see JavaScript: 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. JavaScript: Array Basics
  2. JavaScript: Understand JS Array
  3. JavaScript: Create Array
  4. JavaScript: Sparse Array
  5. JavaScript: What's Array-Like Object?
  6. JavaScript: How to Convert Array-Like Object to Array?
  7. JavaScript: Array How-To

  1. JavaScript: Array Object
  2. JavaScript: Array.prototype

Object Reference

  1. JavaScript: Object Object
  2. JavaScript: Array Object
  3. JavaScript: Function Object
  4. JavaScript: String Object
  5. JavaScript: RegExp.prototype
  6. JavaScript: Date Object
  7. JavaScript: Set Object
  8. JavaScript: Map Object
  9. JavaScript: JSON Object
  10. JavaScript: Math Object
  11. JavaScript: Reflect Object
Like what you read? Buy JavaScript in Depth
or, buy a new keyboard, see Keyboard Reviews.