InterviewSolution
| 1. |
Explain synchronous and asynchronous programming? |
|
Answer» Most websites rely on HTTP calls to fetch the DATA from a SERVER. It takes time for a function to fetch data from an API over HTTP. In synchronous programming, the browser runs the script one line at a time, in order, and waits for the instruction to be completed before moving to the next line. The PROBLEM with synchronous programming is that, while a function is running, the program becomes completely unresponsive. On the other hand, asynchronous programming was devised which enables your script to start a potentially long-running task, but instead of waiting for the task to be finished, the browser can be responsive to other events while the task is running simultaneously. As soon as the task is finished, the script presents the result. This allows users to continue using the APPLICATION, while processes are running in the background, thus ENHANCING the user experience. |
|