r/programming • • Jul 25 '13

CoffeeScript's Scoping is Madness

http://donatstudios.com/CoffeeScript-Madness
207 Upvotes

315 comments sorted by

View all comments

Show parent comment

1

u/a_marklar Jul 26 '13

So I think the coffescript for that would be:

allDivs.on 'mouseover', () ->
    button.click () => $(@).html 'You clicked'

Where => binds the 'this' and @ references it. I'm no javascript dev, but why would you want to bind the 'this' of the callback function anyway?