Ad
  • Default User Avatar

    it might be, that the passed function invokes the function again.

    e.g.

    myDiv.onclick = once ->
      console.log "hello world"
      myDiv.onclick() # recursive loops ftw, all your CPU are belong to us
    

    would run the myDiv.onclick more than once if you place shouldRun = false AFTER executing the function. This is why you should place it first.