How do I define global variables in CoffeeScript?

后端 未结 8 2290
说谎
说谎 2020-11-22 05:41

On Coffeescript.org:

bawbag = (x, y) ->
    z = (x * y)

bawbag(5, 10) 

would compile to:

var bawbag;
bawbag = function(         


        
8条回答
  •  爱一瞬间的悲伤
    2020-11-22 05:43

    I think what you are trying to achieve can simply be done like this :

    While you are compiling the coffeescript, use the "-b" parameter.

    -b / --bare Compile the JavaScript without the top-level function safety wrapper.

    So something like this : coffee -b --compile somefile.coffee whatever.js

    This will output your code just like in the CoffeeScript.org site.

提交回复
热议问题