singularity

Prototypes

How are objects linked? Prototypes

The prototype property

Getting prototype of any object

Object.prototype - parent of all objects

  console.log(Object.getPrototypeOf(obj) === Object.prototype); 
  //true 
  
  console.log(obj.toString()); 
  // [object Object]

Function function

Problems with __proto__

Object.create method

Null prototype object

const obj = Object.create(null);
console.log(obj.toString());
// Error: toString not defined
Object.prototype.isAdmin = true;

ES2015 classes