Categories
Uncategorized

JavaScript Parentheses

Last week I generated some unexpected results by using my_function() instead of my_function as a setTimeout callback.

If you’ve never done that, what happens is my_function() will call the function right away. That makes for an especially unhelpful result with setTimeout, where you would expect it to get called when the timer fires.

I don’t even remember how many years ago I learned about the difference between the two, and I still managed to miss it at first glance.