Search code examples
jqueryrecursioncontinuations

Is continuation-style-programming prone to stack overflow


In response to this question about jQuery effects, I thought about using the callback argument to .fadeIn( 500, my_function ).

While in principle, this is a viable idea, I have no clue (and neither has the jQuery documentation :( ) if the callback is allowed to recurse:

function keep_animating(){
   $("#id").fadeIn(500).fadeOut(500, keep_animating );
}

Solution

  • You could add a debugger breakpoint and test if the stack size increases or not. :)

    However, since animations/fadings use setTimeout/setInterval I highly guess that the call depth does not increase, i.e. it's not prone to stack overflows.