JavaScript [as a script] is single-threaded, but the browser it works with can use the OSβs multithreading capabilities.
If a programmer is required, there are several ways to make pieces of Javascript code in a multi-threaded environment:
- Using the
setTimeout() method, which queues the piece of the piece passed to it as a parameter. - Using ActiveX / Applet / Flash components: which are internal code running inside a browser or a separate process. Javascript can take control of these components and can call methods on them.
In addition, all AJAX calls are multi-threaded, as they occur through ActiveX and support callbacks.
Therefore, the JavaScript concept, which is single-threaded, is wrong ... It restricts the user from creating and processing threads.
source share