return named function in coffeescript

痞子三分冷 提交于 2019-12-12 04:39:16

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!