0

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

1 Answers1

1

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);
});
kba
  • 1,117
  • 9
  • 20