Skip to content

Instantly share code, notes, and snippets.

@neufeldtech
Created September 20, 2016 14:56
Show Gist options
  • Save neufeldtech/5914a0814c954f78b6acceab29bb4db1 to your computer and use it in GitHub Desktop.
Save neufeldtech/5914a0814c954f78b6acceab29bb4db1 to your computer and use it in GitHub Desktop.
http://stackoverflow.com/questions/8965855/coffeescript-when-to-use-fat-arrow-over-arrow-and-vice-versa
Yo yo, this might help understanding the @ symbol and fat and skinny arrows.
Notice that the context of the @ symbol is inside a class.
Notice that the context of the fat vs skinny arrows are when dealing with callbacks.
class Test
constructor: ->
@canvas = document.createElement 'canvas'
window.addEventListener 'resize', ->
@canvas.width = window.innerWidth
@canvas.height = window.innerHeight
works: (@canvas defined)
class Test
constructor: ->
@canvas = document.createElement 'canvas'
window.addEventListener 'resize', =>
@canvas.width = window.innerWidth
@canvas.height = window.innerHeight
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment