olivernn/augment.js — Issue #12: ES5 bind
Author: Raynos
Created: 2012-01-19 10:50:38+00:00
State: open

```
bound = function () {
return self.apply( nop.prototype && this instanceof nop ? this : ( obj || {} ),
args.concat( slice.call(arguments) ) );
};
```

http://es5.github.com/#x15.3.4.5

> Set the [[Construct]] internal property of F as described in 15.3.4.5.2.

http://es5.github.com/#x15.3.4.5.2

> Return the result of calling the [[Construct]] internal method oftarget providing args as the arguments.

http://es5.github.com/#x13.2.2

> Return obj.

Basically your code always returns the return value of the bound function and doesn't handle cases like

```
new ( (function () {
return undefined;
}).bind(lulz, args) ) !== undefined;
```

Here the return value of invoking `new` (and `[[Construct]]`) on the bound function should be that the new instance is returned, not the return value of the bound function.

Again see es5-shim for implementation.