在 Nodejs 中使用 d8 函数
Use d8 functions in Nodejs
今天,我决定第一次使用 JavaScript 参加在线编程竞赛,但这让我遇到了麻烦!我本地的Nodejs版本是v10.16.1 但是网上评委用的是V8JavaScript引擎
直到今天我还以为 Nodejs 使用 V8 作为 JavaScript 引擎;但是不幸的是,我今天不能在 Nodejs 中使用 readline
和 print
d8 的内置函数。
那么Nodejs默认支持V8吗?
- 如果没有,我如何与 Nodejs 一起安装 d8 以及如何使用它?
- 如果是,我该如何启用它?
如有任何回应,我们将不胜感激...
编辑:据我了解,那个在线法官没有嵌入V8;它只是使用 d8 as it's environment which is a shell (interface) for V8 and readline
and print
是 d8(不是 V8)的内置函数。
编辑: This question is related to using JavaScript in online contests. Also this 一个对如何使用 d8 有帮助。
V8 是一个 Javascript 引擎。它没有自己的用户界面,所以它不能 运行 Javascript 完全靠自己。它是给开发者的。开发人员将 V8 链接到他们的程序中,以便能够从他们的程序中 运行 Javascript。
Chrome 浏览器使用 V8.
Nodejs 使用 V8。
D8 (a programming shell) 使用 V8.
因此,如果您想 运行 Javascript 使用 V8,您必须 运行 这些程序之一内置了 V8。
So Does Nodejs support V8 by default?
是的,V8 内置于 Nodejs 中。
If no, how can I install V8 alongside Nodejs and how can I use it? (I prefer pre-built and binary version)
它已经内置了。
If yes, how can I enable it?
Nodejs环境默认开启
Until today I thought Nodejs uses V8 as JavaScript engine; however unfortunately I can't use readline and print built-in functions of V8 in Nodejs today.
您必须在 node.js 中使用 readline 显示您的具体代码和问题。 readline
内置于 node.js 中,不是 V8 的一部分。 documentation for something like readline 非常清楚地显示了如何使用它的示例。您必须首先加载 readline 模块,然后使用该模块中的方法。
Today I decided to compete in an online programming contest using JavaScript for the first time but It got me in trouble! My local version of Nodejs was v10.16.1 but the online judge used V8 JavaScript engine.
在线比赛不太可能直接使用 V8。他们可能使用本身链接了 V8 的编程环境。您需要更具体地说明编程竞赛使用的是什么编程环境。它是否使用特定版本的 Nodejs?还是像D8这样的编程shell?还是浏览器?
今天,我决定第一次使用 JavaScript 参加在线编程竞赛,但这让我遇到了麻烦!我本地的Nodejs版本是v10.16.1 但是网上评委用的是V8JavaScript引擎
直到今天我还以为 Nodejs 使用 V8 作为 JavaScript 引擎;但是不幸的是,我今天不能在 Nodejs 中使用 readline
和 print
d8 的内置函数。
那么Nodejs默认支持V8吗?
- 如果没有,我如何与 Nodejs 一起安装 d8 以及如何使用它?
- 如果是,我该如何启用它?
如有任何回应,我们将不胜感激...
编辑:据我了解,那个在线法官没有嵌入V8;它只是使用 d8 as it's environment which is a shell (interface) for V8 and readline
and print
是 d8(不是 V8)的内置函数。
编辑: This question is related to using JavaScript in online contests. Also this 一个对如何使用 d8 有帮助。
V8 是一个 Javascript 引擎。它没有自己的用户界面,所以它不能 运行 Javascript 完全靠自己。它是给开发者的。开发人员将 V8 链接到他们的程序中,以便能够从他们的程序中 运行 Javascript。
Chrome 浏览器使用 V8.
Nodejs 使用 V8。
D8 (a programming shell) 使用 V8.
因此,如果您想 运行 Javascript 使用 V8,您必须 运行 这些程序之一内置了 V8。
So Does Nodejs support V8 by default?
是的,V8 内置于 Nodejs 中。
If no, how can I install V8 alongside Nodejs and how can I use it? (I prefer pre-built and binary version)
它已经内置了。
If yes, how can I enable it?
Nodejs环境默认开启
Until today I thought Nodejs uses V8 as JavaScript engine; however unfortunately I can't use readline and print built-in functions of V8 in Nodejs today.
您必须在 node.js 中使用 readline 显示您的具体代码和问题。 readline
内置于 node.js 中,不是 V8 的一部分。 documentation for something like readline 非常清楚地显示了如何使用它的示例。您必须首先加载 readline 模块,然后使用该模块中的方法。
Today I decided to compete in an online programming contest using JavaScript for the first time but It got me in trouble! My local version of Nodejs was v10.16.1 but the online judge used V8 JavaScript engine.
在线比赛不太可能直接使用 V8。他们可能使用本身链接了 V8 的编程环境。您需要更具体地说明编程竞赛使用的是什么编程环境。它是否使用特定版本的 Nodejs?还是像D8这样的编程shell?还是浏览器?