How Does JavaScript Work Behind the Scenes?
JavaScript was designed to run only in browsers so every browser has what we call a JavaScript engine that can execute JavaScript code.
For example, the JavaScript engines in Firefox and Chrome are SpiderMonkey and V8.
In 2009, a very clever engineer called Ryan Dahl took the open-source JavaScript engine in Chrome and embedded it inside a C++ program. He called that program, node.
Node is a C++ program that includes Google's V8 JavaScript engine. Now with this, we can run JavaScript code out of a browser. So, we can pass our JavaScript code to the node for execution. This means, that with JavaScript, we can build the backend for our web and mobile applications.
So, in a nutshell, JavaScript code can be run inside of a browser, or in a node. Browsers and node provide a runtime environment for our JavaScript code.
?? If you need help learning to code, I just relaunched my course The Art of Web Development. It's 60% OFF for a limited time( normally $600). Sign up here.
Happy Coding!