Javascript Engine vs Runtime

JavaScript Engine

A JavaScript engine is a program or interpreter which reads our JavaScript code, produces machine code, and finally runs the machine code. It is landed in JavaScript runtimes like web browsers, Node.js, or even Java Runtime Environment (JRE). Like any other interpreters, its job is to read and execute code.

JavaScript Runtime

JavaScript runtime is another software. It uses JavaScript Engine and provides some additional functionalities as needed. The most common example of the runtime is the web browser. Probably the second most widely used runtime is Node.js.

A browser provides APIs which are applicable for a program to run in a browser. Browser APIs are like DOM manipulation APIs, windows and document APIs. On the other hand, Node.js provides APIs which are applicable for a server application. Such APIs are like require, process, and buffer APIs.

A metaphor

imagine a robot is putting out a fire:

  • The JavaScript code would be the instructions to the robot to put out a fire.
  • The JavaScript engine would be the robot which can understand the instructions and act on it.
  • The JavaScript runtime would be the fire truck, and the water gun.

Reference

Uncover the JavaScript: Engine vs Runtime | by Md. Misbahul Alam Chowdhury | Medium What is the difference between JavaScript Engine and JavaScript Runtime Environment - Stack Overflow