Skip to content

Instantly share code, notes, and snippets.

@davidvandusen
Created March 14, 2015 21:45
Show Gist options
  • Save davidvandusen/11bbb17c3cbfdcfe4d67 to your computer and use it in GitHub Desktop.
Save davidvandusen/11bbb17c3cbfdcfe4d67 to your computer and use it in GitHub Desktop.
JavaScript prototype behaviour
function Thing() {}
//undefined
var t = new Thing();
//undefined
t instanceof Thing
//true
t instanceof Object
//true
Thing.prototype.__proto__
//Object {}
t.__proto__
//Thing {}
Thing.prototype
//Thing {}
t.__proto__ = String.prototype;
//String {length: 0, [[PrimitiveValue]]: ""}
t instanceof Thing
//false
t instanceof String
//true
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment