Skip to content

Instantly share code, notes, and snippets.

@evilpie
Created August 16, 2011 13:12
Show Gist options
  • Save evilpie/1149041 to your computer and use it in GitHub Desktop.
Save evilpie/1149041 to your computer and use it in GitHub Desktop.
blabla
so well
var f = function () {};
var bound = f.bind({});
(new bound) instanceof bound;
V = new bound;
bound[[HasInstance]](V);
/* inside 15.3.4.5.3 [[HasInstance]] (V) */
if (!bound[[Target]))
throw;
target = bound[[Target]]
target[[HasInstance]](V)
/* target is just |f| */
/* at this point this is the same as (new bound) instanceof f */
/* 15.3.5.3 [[HasInstance]] (V) */
if (!IsObject(V))
throw;
prototype = target.prototype;
do {
V = V.__proto__; /* V proto is going to be f.prototype, because (new bound) is about the same as (new f)
if (V === null)
return false;
if (V === prototype)
return true; /* yaay ! */
} while (true);
@jdalton
Copy link

jdalton commented Aug 16, 2011

Well crap, you guys are right. Here is the V8 bug report and explanation by Luke that made it click for me :D

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment