dotslash dotslash - 9 months ago 47
Javascript Question

Objects returned from constructor do not have a prototype

I came across this passage in the wonderful book Eloquent JavaScript:

Constructors (in fact, all functions) automatically get a property
named prototype, which by default holds a plain, empty object that
derives from Object.prototype. Every instance created with this
constructor will have this object as its prototype.

So I thought I'll test it.

function Person () {}

person = new Person()

console.log(Person.prototype) // Object {}
console.log(person.prototype) // undefined ???? :O

The first
makes sense, but why does the second one show


Use Object.getPrototypeOf to get the prototype of specified object

function Person() {}
person = new Person();