Closed recursive-beast closed 4 years ago
False alarm.
There are two versions of Function.prototype.bind
polyfills in the MDN website:
new
keyword, which is the one that's causing this
to be the global object.I was working with the first one.
I'm trying to get sql-bricks to work on an old environment, specifically Classic ASP using JScript as the scripting language ( javascript in es3 spec ).
everything is working fine when I'm using the standalone library, but when I'm using the mysql-bricks extension, I get an error indicating an "out of stack space" error.
After a day and a half of trying to fix the problem, I discovered that the problem is coming from the subclass function. The
this
value insidecls
seems to cause the issue, If I try to print it every timecls
is called here's the result:The first time,
this
iscls
itself, then it's always the global object, which makes the condition!(this instanceof cls)
always true, becauseapplyNew
gets called recursively, which in turn callscls
with athis
value set tonull
(global object).I'm not sure why does this happen, maybe you could shed some light on this?