I'm getting the error Uncaught TypeError: Function.prototype.apply: Arguments list has wrong type
when I use the .apply()
method and I'm not sure why. My code is here.
When jsfiddle loads up, click next to the word test and hit the Enter key. The method that the error is occurring in is this.addEvent
. I'm trying to have my object be the 'this' in the event's callback function.
You should use .call
instead of .apply
.
a.apply(obj, lst)
is equivalent to a(lst[0], lst[1], lst[2], ...)
when lst
is an Array (or arguments
) using obj
as this
.
a.call(obj, x, y, z, ...)
is equivalent to a(x, y, z, ...)
using obj
as this
.
Since e
is one of the arguments, not an array of arguments, you should use .call
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With