funName = () ->
$(".foo").addClass("bar");
Compiles into the scope of an anonymous function. Calling funName
from the console results in undefined
.
(function() {
var funName;
funName = function() {
return $(".foo").addClass("bar");
};
}).call(this);
What's its reasoning for compiling like this and how do I work with it?
Also any insight on the mandatory return within functions using CoffeeScript would be great. Why is it like that? How do I need to code differently because of it?