I have been writing coffeescript for a while and have come across something a bit strange.
Traditionally, coffeescript declares all prototype methods separately:
MyClass.prototype.firstMethod = function(){...};
MyClass.prototype.secondMethod = function(){...};
However, MDN says it's better to do this:
(function() {
this.firstMethod = function(){...};
this.secondMethod = function(){...};
}).call(MyClass.prototype);
For the source, please refer to the very end of the example on this page .
I got the impression that coffeescript is trying to display the best javascript. Is one way really better (or perhaps another) than the other, or is it just a preference?
Thanks for reading!
EDIT: This question seems to have no real answer and comes down to the question of opinion. I will leave it for another 2 hours before deleting it. I would like to thank everyone for their contribution, this helped me to better understand this topic.