How do I define global variables in CoffeeScript?

后端 未结 8 2211
说谎
说谎 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条回答
  •  萌比男神i
    2020-11-22 05:56

    To add to Ivo Wetzel's answer

    There seems to be a shorthand syntax for exports ? this that I can only find documented/mentioned on a Google group posting.

    I.e. in a web page to make a function available globally you declare the function again with an @ prefix:

    
    
    Click me!
    

提交回复
热议问题