3 ms·
Another exception, functions invoked with setInterval have 'this' be window, even if they're invoked in context with it's own 'this'. This got me the other day.
by cwmma 14y ago
Another exception, functions invoked with setInterval have 'this' be window, even if they're invoked in context with it's own 'this'. This got me the other day.
https://developer.mozilla.org/en-US/docs/DOM/window.setInterval#The_.22this.22_problem https://developer.mozilla.org/en-US/docs/DOM/window.setInter...
- jQueryIsAwesome 14y agoA workaround that I like a little more: http://javascriptisawesome.blogspot.com/2011/11/setinterval-with-context.html http://javascriptisawesome.blogspot.com/2011/11/setinterval-...
- cwmma 14y agoThere are totally a bunch of workarounds, it's just another exception to this, I was using CoffeeScript so I was able to grossly simplify the MDN one https://github.com/calvinmetcalf/communist/blob/master/src/socialist.coffee#L9-L16 https://github.com/calvinmetcalf/communist/blob/master/src/s...