This post is about how this unexpected behaviour led me into having a refresher of some of the core concepts regarding how JavaScript executes.
I and a colleague at work, were implementing a piece of functionality which basically translates to: "Create a function such that if that function is called with a delay flag being true, have a timeout for a line within the function, if not, then call that line immediately". Something like this...
Ok. Then it is obvious I've got something new to learn here. So I decide to dig more into why this is the case. A couple of researching got me the reason behind this behaviour. And to understand why things tie up this way, I needed to revisit what it meant by JavaScript being single threaded, non blocking I/O and has an asynchronous event queuing model for code execution.
Your new post is loading...