Created
November 6, 2012 23:21
-
-
Save karolk/4028402 to your computer and use it in GitHub Desktop.
How instanceof works
This file contains hidden or 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 A() {} | |
var a = new A() | |
a instanceof A | |
//true | |
//swap the prototype | |
A.prototype = {} | |
a instanceof A | |
//false | |
//instanceof checks if the function prototype is the same as objects __proto__ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment