问题
I have the following javascript:
Function.prototype.debounce = function (threshold, execAsap) {
var func = this, timeout;
return function debounced () {
//body
}
};
How can I return a named function like this in coffeescript?
回答1:
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.
来源:https://stackoverflow.com/questions/13462589/return-named-function-in-coffeescript