Javascript is a highly asynchronous programming language. No matter if you play with ajax calls or a MongoDb query in Node.js, you will step over loads of callbacks being executed asynchronously.
When working with synchronous programming, you know that your code will execute sequentially, starting from the top of the code going downwards.
But When code is executed asynchronously, you provide a callback function to a the asynchronous function. The asynchronous function will then go on and be executed in the background, at the same time as your main code continues to execute. When the asynchronous function is done, the callback function will be called, and you have code being executed in parallel.
But, and this is a rather big one, asynchronous code quickly becomes horribly spaghetti-codish. You have callbacks for successful get’s, callbacks on errors, and when you put an asynchronous call within another, the code will look something written in the eighties.
Your new post is loading...