如何在CoffeeScript中创建命名函数表达式?

scr*_*key 1 javascript coffeescript

如何在CoffeeScript中创建一个命名函数表达式,如下例所示?

var a = function b (param1) {}
Run Code Online (Sandbox Code Playgroud)

要么

return function link (scope) {}
Run Code Online (Sandbox Code Playgroud)

nae*_*th7 5

我可能有点迟到了,但我刚刚意识到你实际上在使用class关键字时创建了命名函数.

例:

class myFunction
  # The functions actual code is wrapped in the constructor method
  constructor: ->
    console.log 'something'

console.log myFunction # -> function AppComponent() { ... }
myFunction() # -> 'something'
Run Code Online (Sandbox Code Playgroud)