To me it seems @atomicules has the simplest answer, but I think it can be simplified a little more. You need to put an @
before anything you want to be global, so that it compiles to this.anything
and this
refers to the global object.
@bawbag = (x, y) ->
z = (x * y)
bawbag(5, 10)
this.bawbag = function(x, y) {
var z;
return z = x * y;
};
bawbag(5, 10);
(function() {
this.bawbag = function(x, y) {
var z;
return z = x * y;
};
console.log(bawbag(5,13)) // works here
}).call(this);
console.log(bawbag(5,11)) // works here