JavaScript Engine和JavaScript Runtime Environment之间有什么区别
我感到有点困惑,有人可以帮忙描述JavaScript Engine和JavaScript Runtime Environment之间的区别。
BTW,事件循环是在引擎还是运行时实现的?
I'm feeling a bit confused, could someone help to describe What is the difference between JavaScript Engine and JavaScript Runtime Environment. BTW, Event Loop was implemented in Engine or Runtime?
与C和其他编译语言不同,Javascript运行于容器 - 读取js代码并运行它们的程序。这个程序必须做两件事
Unlike C and other compiled languages, Javascript runs in a container - a program that reads your js codes and runs them. This program must do two things
- 解析你的代码并将其转换为runnable命令
- 提供一些javascript的对象,以便它可以与外部世界进行交互。
第一部分称为Engine,第二部分是Runtime。
The first part is called Engine and the second is Runtime.
例如,Chrome浏览器和node.js使用相同的引擎 - V8,但它们的运行时不同:在Chrome中你有窗口
,DOM对象等,而节点给你 require
,缓冲区和进程。
For example, the Chrome Browser and node.js use the same Engine - V8, but their Runtimes are different: in Chrome you have the window
, DOM objects etc, while node gives you require
, Buffers and processes.