For Javascript in Browser and node.js, I am trying to understand the difference between the thread pool and Web API. Both the thread pool, and Web API, enable Javascript to handle asynchronous behavior, so how they are different? Web API after completion of the task sends the task to the Queues from where the task is sent back to the call stack. How do Thread Pool and NodeJS work to imitate asynchronous behavior?
They are completely unrelated.
The main event loop is where most JavaScript code you write runs.
Expensive operations (such as file access or code you explicitly run in a worker) are often done outside of the main event loop. This frees up the main event loop to do other work.
We say something is asynchronous when it is performed outside the main event loop because it isn't done in sequence with the rest of the work the main event loop is doing.
The thread pool is just how Node.js' particular implementation manages those asynchronous tasks.
The Web APIs are a set of classes/functions/etc provided to JavaScript programs that run in browsers which have functionality that is often desired in JS programs that are embedded in webpages but which are not part of the JavaScript language.
e.g. the Object constructor is a core part of JavaScript, while the HTML DOM API is a Web API.
Some of those features (such as XMLHttpRequest) do work outside the main event loop, but that isn't an intrinsic feature of Web APIs (e.g. the DOM API doesn't).
Node.js puts equivalent functionality in built-in modules (such as the fs module).