Till now, you have learned a lot about JavaScript. But there’s more to this mysterious language. Understanding this session is very important if you want to master JavaScript. In the next video, you’ll hear from Srishti and learn a bit more about JavaScript.
In the last video, you learned an important aspect of JavaScript:
JavaScript is a single-threaded synchronous language which executes all the code line by line in the order in which it is written.
You also looked at an example to prove this fact. Let us now extend this example. In the next video, you’ll watch Srishti map these tasks to real-life.
In the last video, you looked at how you could write some code that does not produce the output in the order you had specified in the code. This is possible due to the asynchronous behaviour of JavaScript. In the next video, you’ll learn from Srishti about what asynchronous behaviour is.
In the last video, you learned that though JavaScript is a synchronous programming language, yet you can write asynchronous code in it. In asynchronous programming, you can do tasks without waiting for a task to complete its execution. Even when a long-running task starts, the remaining program code continues to run and when the task gets complete, the program is informed and gets access to the result. In short, you can run some code in the background while the main code continues getting executed. Thus, this helps in utilization of time & resources.
Running the code in background essentially means running them inside Web APIs. You’ll now hear from Sakshi in the next video about how Web APIs work while looking at a simple example.
In the last video, you looked at how the Web APIs and event loop work together to make JavaScript exhibit asynchronous behaviour.