Dhruv Saxena Dhruv Saxena -5 years ago 487
CoffeeScript Question

comma in coffee script / framerjs

When do we use a comma after function declaration in coffee script?
For eg, in the code below why is there a comma after Events.DragStart?

layerA.on Events.DragStart, ->
print layerA.draggable.layerCursorOffset

Answer Source

The comma is not after the function declaration but after the first argument. Coffeescript is just a syntax for Javascript, so you can always compile it to Javascript to see what it does.

E.g. pasting your code snippet into the js2.coffee web service yields this Javascript:

layerA.on(Events.DragStart, function() {
  return print(layerA.draggable.layerCursorOffset);
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download