Calling coffeescript functions from console

前端 未结 4 985
南旧
南旧 2020-12-29 07:30

Playing a little with coffeescript and Rails 3.1.0.rc4. Have this code:

yourMom = (location) ->
  console.log location

yourMom \"wuz hur\"
4条回答
  •  天命终不由人
    2020-12-29 08:03

    an easier way to share global methods/variables is to use @ which means this.

    @yourMom = (location) ->
      console.log location
    
    yourMom "wuz hur"
    

    Nicer syntax and easier to read, but I don't encourage you to create global methods/variables

提交回复
热议问题