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
.callinstead of.apply.a.apply(obj, lst)is equivalent toa(lst[0], lst[1], lst[2], ...)whenlstis an Array (orarguments) usingobjasthis.a.call(obj, x, y, z, ...)is equivalent toa(x, y, z, ...)usingobjasthis.Since
eis one of the arguments, not an array of arguments, you should use.call.