May 09, 2021 CoffeeScript
You want to call the same function in a function.
Use a named function:
ping = ->
console.log "Pinged"
setTimeout ping, 1000
If it is an unnamed function, use @arguments.callee:
delay = 1000
setTimeout((->
console.log "Pinged"
setTimeout arguments.callee, delay
), delay)
Although arguments.callee allows recursion of unnamed functions, which has some advantages in memory-intensive applications, named functions are relatively clear-purpose and easier to maintain code.