Open smj-edison opened 5 years ago
The editor transforms your code and replaces new
in the ast with a custom instantiation mechanism. This is why you're seeing the results you're getting. Function.bind
is working correctly, it's this instantiation mechanism that has been plagued with issues like this for quite a while.
I was running examples from You Don't Know JS, and when I plugged this into the live editor, it gave the wrong results:
I confirmed that it normally works by replacing
println
withconsole.log
, and running it in the debugger. The debugger gave all the expected values. Something withfoo.bind
isn't working correctly (which doesn't make sense, because it returns native code), or thenew
constructor isn't accounting for function bindings.EDIT: added example: https://www.khanacademy.org/computer-programming/_/6379005266198528