Created
March 14, 2015 21:45
-
-
Save davidvandusen/11bbb17c3cbfdcfe4d67 to your computer and use it in GitHub Desktop.
JavaScript prototype behaviour
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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