JS: Object.prototype

By Xah Lee. Date: . Last updated: .

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

〔►see JS: Object Object

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

Type of Object.prototype is object. That is, same type as {}.

〔►see JS: Data Types

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

Object.prototype is the root parent of all standard objects.

Parent of Object.prototype is null.

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

〔►see JS: Prototype and Inheritance

All standard objects inherit from Object.prototype. So, for any property key k of Object.prototype, you can access it by obj.k where obj is any object. If the object obj has k as its own property, the own property is used.

Properties


Object.prototype.constructor

Object.prototype.constructor

Value is the function object Object.

〔►see JS: Property Key "constructor"

〔►see JS: Object Object

console.log(Object.prototype.constructor === Object); // true
console.log({}.constructor === Object); // true

Object.prototype.hasOwnProperty

〔►see JS: Object.prototype.hasOwnProperty

Object.prototype.isPrototypeOf

〔►see JS: Object.prototype.isPrototypeOf

Object.prototype.propertyIsEnumerable

〔►see JS: Object.prototype.propertyIsEnumerable

Object.prototype.toString

〔►see JS: Object.prototype.toString

Object.prototype.toLocaleString

ECMAScript 2015 §Fundamental Objects#sec-object.prototype.tolocalestring

Object.prototype.valueOf

〔►see JS: Object.prototype.valueOf

Reference

ECMAScript 2015 §Fundamental Objects#sec-object.prototype

Object and Inheritance Topic

  1. JS: Object System Overview
  2. JS: What's Object?
  3. JS: Prototype and Inheritance
  4. JS: Create Object
  5. JS: Object Literal Expression
  6. JS: Find Object's Prototype
  7. JS: How to Create Object with Parent X?
  8. JS: Prevent Adding Property
  9. JS: Determine Type of Object
  10. JS: Primitive Value Object Wrapper
  11. JS: Clone, Deep Copy Object/Array
  12. JS: Test Equality of Objects

  1. JS: Object Object
  2. JS: Object.prototype
Like what you read? Buy JavaScript in Depth