Created
August 16, 2011 13:13
-
-
Save DavidBruant/1149046 to your computer and use it in GitHub Desktop.
bound functions and instanceof
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 f(){} | |
var g = f.bind({}); | |
var newg = new g; | |
// call g.[[Construct]] (which is f.[[Construct]] per ES5.1 15.3.4.5 step 13) | |
// so, |new g| is the same as |new f|: an object which has f.prototype as [[Prototype]] | |
newg instanceof g; | |
// instanceof g calls the g.[[HasInstance]](newg) (please forgive my skip of reference/GetValue mess) | |
// As per ES5.1 - 15.3.4.5.3, g.[[HasInstance]](V) is g.[[TargetFunction]].[[HasInstance]](V) | |
// which is f.[[HasInstance]](V) | |
// ==> g.[[HasInstance]](newg) === f.[[HasInstance]](newg) === true |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
discussion continued at: https://gist.github.com/1149041