Skip to content

Instantly share code, notes, and snippets.

@JeOam
Last active June 7, 2017 07:31
Show Gist options
  • Save JeOam/f2b1ee0200dc153428106b2f585bb6f6 to your computer and use it in GitHub Desktop.
Save JeOam/f2b1ee0200dc153428106b2f585bb6f6 to your computer and use it in GitHub Desktop.
__proto__ VS. prototype

__proto__ is the actual object that is used in the lookup chain to resolve methods, etc. prototype is the object that is used to build __proto__ when you create an object with new.

function Point(x, y) {
    this.x = x;
    this.y = y;
}

var myPoint = new Point();

// the following are all true
myPoint.__proto__ == Point.prototype
myPoint.__proto__.__proto__ == Object.prototype
myPoint instanceof Point;
myPoint instanceof Object;

via click

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment