We're looking for a person or people to help audit MDN to find places we could speed up. Is this you or someone you know? Check out the RFP: https://mzl.la/2IHcMiE


(function(){return this;}).bind(null)() === window; //this returns true in native implementations and false in the current compatibility code.

On line 11, "( obj || {} )" if this read "( obj || (window || {}) )" it would behave like the native bind when "thisArg" is null.

Another issue on line 11 in Safari (I was running SF5 for windows) meant I needed to change this:

"this instanceof nop" to this: "(nop.prototype && this instanceof nop)"

To test this in safari, execute this line (after adding the bind compatibility code of course):

console.log.bind(console, "foo")("bar")

nop function is useless

Line 17 of the partial implementation was recently changed to "bound.prototype = this.prototype;". It used to be two lines:

nop.prototype = self.prototype;
bound.prototype = new nop();

Which made the check for "this instanceof nop" work when "bound" is called as a constructor. As it is, the check will always fail since it's impossible to create an object that gets nop's prototype. The change appears to be attempting to keep the existing prototype property, but from looking at the spec, the bound function isn't supposed to have a .prototype anyway. I haven't dug into enough to know for sure if the old code was correct so I'm not changing it back, but as it is now, some of the code is useless and the returned function doesn't work correctly as a constructor.

Document Tags and Contributors

 Contributors to this page: silentmatt, RickB
 Last updated by: silentmatt,