是否有类似MoonScript的JavaScript的arguments.callee
之类的东西?
Since Moonscript functions are defined as local func; func = function() end
local func; func = function() end
, they are all recursive. This will print 120:
recursive = (n) -> return n > 1 and n*recursive(n-1) or 1
print recursive 5
As far as I know, there is no arguments.calee
alternative, but I haven't seen cases where I'd need it either. Even Mozilla's docs say "there are nearly no cases where the same result cannot be achieved with named function expressions" about arguments.callee
.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.