Before Node

Before Node, we only used JavaScript to build applications that run inside of a browser. Every browser has a JavaScript Engine that takes your JavaScript code and turns it into an executable form

A JavaScript engine, at its core, consists of an interpreter and a runtime environment.

  • JavaScript was (and still is considered) as an interpreted language. This means the JavaScript engine in a browser reads over the JavaScript code, interprets each line, and runs it.
  • Modern browsers, however, use a technology known as Just-In-Time (JIT) compilation, which compiles JavaScript to executable bytecode just as it is about to run. The bytecodes are then executed using a JavaScript Runtime Environment.
  • The runtime environment inside a browser provides global objects such as window and document that enable JavaScript to interface with the browser and the webpage it is part of.

In 2009, Ryan Dahl took Google's V8 engine, embedded it in a C++ program, and called Node.

Node uses Google's V8 to convert JavaScript into bytecodes but runs it outside of a browser.

We don't have browser environment objects such as window or the document object in Node. Instead, we have other things not available in browsers, such as objects for working with the file system, network, operating system, etc.

I recommend consulting the following resources if you are interested to learn more about the JavaScript Engine and how your code is executed.

Resources