`new` is not detecting explicitly bound functions
- Dominant language
- JavaScript
- Stars
- 776
- Forks
- 180
- PR merge metrics
- No merged PRs in 30d
Description
I was running examples from _You Don't Know JS_, and when I plugged this into the live editor, it gave the wrong results:
```
var foo = function(something) {
this.a = something;
};
var obj1 = {};
var bar = foo.bind( obj1 );
bar( 2 );
println( obj1.a ); // expected 2, actual 2
var baz = new bar( 3 );
println( obj1.a ); // expected 2, actual 3
println( baz.a ); // expected 3, actual undefined
```
I confirmed that it normally works by replacing `println` with `console.log`, and running it in the debugger. The debugger gave all the expected values.
Something with `foo.bind` isn't working correctly (which doesn't make sense, because it returns native code), or the `new` constructor isn't accounting for function bindings.
EDIT: added example: https://www.khanacademy.org/computer-programming/_/6379005266198528
Contributor guide
No contributing guide indexed for this repository
Research direction
Start in the live editor's JavaScript execution path and reproduce the provided example involving foo.bind, bar, and new bar. Trace how bound functions and constructor calls are handled; done means the example prints 2 for obj1.a and 3 for baz.a as shown in the expected results.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- web-dev
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100