在javascript中你会写如下:
method.apply(this,arguments);
Run Code Online (Sandbox Code Playgroud)
但是,你怎么把它翻译成coffeescript?:
method.apply(@, arguments)
Run Code Online (Sandbox Code Playgroud)
参数变量有不同的名称吗?
And*_*ing 17
使用splats,您可以使用更清洁的coffeescript语法:
caller: ->
@method arguments...
Run Code Online (Sandbox Code Playgroud)
以上编译为以下Javascript:
caller: function() {
return this.method.apply(this, arguments);
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3082 次 |
| 最近记录: |