return coffeescript中的函数 [英] return named function in coffeescript
本文介绍了return coffeescript中的函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有以下javascript:
I have the following javascript:
Function.prototype.debounce = function (threshold, execAsap) {
var func = this, timeout;
return function debounced () {
//body
}
};
如何在coffeescript中返回这样的命名函数?
How can I return a named function like this in coffeescript?
推荐答案
您不能在Coffeescript中命名函数。原因在常见问题中提供 - grep表示有任何方法名称函数,用于反射和递归?如果你真的需要嵌入一个名字,你可以使用反引号来嵌入原始的Javascript。
You can't name functions in Coffeescript. The reason is given in the FAQ -- grep for "Is there any way to name functions, for reflection and recursion?" If you really need to embed a name, you could use backticks to embed raw Javascript.
这篇关于return coffeescript中的函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文