Function#bind [[HasInstance]] question.

Luke Hoban lukeh at microsoft.com
Tue Aug 16 09:12:10 PDT 2011


My interpretation of these spec sections:

(new bound) instanceof bound
=> (new Bar()) instanceof bound // bind's Construct defers to the targetFunction and ignores bound thisValue
=> bound.[[HasInstance]](new Bar()) // meaning of instanceof
=> Bar.[[HasInstance]](new Bar()) // bind's HasInstance defers to the targetFunction
=> true // normal HasInstance 

Similarly for 'new bound instanceof Bar'.    IE and Firefox both appear to agree with this result.

Luke

-----Original Message-----
From: es-discuss-bounces at mozilla.org [mailto:es-discuss-bounces at mozilla.org] On Behalf Of John-David Dalton
Sent: Tuesday, August 16, 2011 7:27 AM
To: es-discuss at mozilla.org
Subject: Function#bind [[HasInstance]] question.

Sorry about the last empty reply, GMail got ahead of itself :D

So Chrome and Firefox disagree on their Function#bind implementation.
http://es5.github.com/#x15.3.4.5.2
http://es5.github.com/#x15.3.4.5.3

~~~ js
function Bar() {
  return 1;
}
var bound = Bar.bind({});
new bound instanceof bound; // Firefox reports `true`, Chrome `false` (I think Chrome is right) new bound instance of Bar; // Firefox and Chrome report `true` ~~~

The test262 doesn't appear to cover this case.
What is the correct result of `new bound instance of bound;` and why?

-JDD
_______________________________________________
es-discuss mailing list
es-discuss at mozilla.org
https://mail.mozilla.org/listinfo/es-discuss



More information about the es-discuss mailing list