You might also like

Object-orientation and inheritance in JavaScript: a comprehensive explanation
JS Minty Fresh: Identifying and Eliminating Code Smells
JsFiddle Tips And Tricks


Joe Lippeatt

Unfortunately, the comments have been turned off for this post. Recursion in JS is available; but as the one commenter suggested, has some serious pitfalls. The writer says "Every time your recursive function is called directly a copy of the function’s variables is added to the stack.[sic]" This alone is a justification to avoid extensive recursive stack-plumping code and use for(;;) loops instead. If a stack is so stuffed and execution time so lengthy that the user can't scroll during a sort operation (the justification for using setTimeout()), there may be justification for handling that activity on the server and retrieving the sorted data via http.

about 5 years ago   Like_icon 0 likes  
Abelardo Gonzalez

There are situations where recursion is legitimately necessary. I don't want to dismiss this completely, just because it may seem impractical in normal scenarios. Deadlines and changing requirements can do a lot to create situations you can't predict, where maybe something like this would be very useful: maybe there is no data connection, maybe you are doing some modeling that you are watching as it's done, etc.

about 5 years ago   Like_icon 0 likes  

Talentopoly Newsletter

A once-weekly round-up of the best programming and design posts.

Join 2050+ subscribers

We will never spam or share your email address. Easily unsubscribe