Top-level variables aren't globally-scoped and return values are mandatory in CoffeeScript

前端 未结 3 616
粉色の甜心
粉色の甜心 2021-01-21 04:19
funName = () ->
  $(\".foo\").addClass(\"bar\");

Compiles into the scope of an anonymous function. Calling funName from the console res

3条回答
  •  离开以前
    2021-01-21 05:24

    If you want to create a global funName try using root = exports ? this and then root.funName = ... as described at How do I define global variables in CoffeeScript?

提交回复
热议问题