¥The objects listed here are specific to Node.js. There are
built-in objects
that are part of the JavaScript language itself, which are also globally
accessible.
¥Returns a new
AbortSignal
which will be aborted if any of the provided
signals are aborted. Its
abortSignal.reason
will be set to whichever
one of the
signals
caused it to be aborted.
¥A browser-compatible implementation of
<Crypto>
. This global is available
only if the Node.js binary was compiled with including support for the
node:crypto
module.
¥A browser-compatible implementation of
<CryptoKey>
. This global is available
only if the Node.js binary was compiled with including support for the
node:crypto
module.
在浏览器中,顶层作用域传统上是全局作用域。这意味着
var something
将定义一个新的全局变量,ECMAScript 模块除外。在 Node.js 中,这是不同的。顶层作用域不是全局作用域;Node.js 模块内的
var something
对于该模块而言是本地的,无论它是
CommonJS 模块
还是
ECMAScript 模块
。
¥In browsers, the top-level scope has traditionally been the global scope. This
means that
var something
will define a new global variable, except within
ECMAScript modules. In Node.js, this is different. The top-level scope is not
the global scope;
var something
inside a Node.js module will be local to that
module, regardless of whether it is a
CommonJS module
or an
ECMAScript module
.
¥A browser-compatible implementation of
localStorage
. Data is stored
unencrypted in the file specified by the
--localstorage-file
CLI flag.
Any modification of this data outside of the Web Storage API is not supported.
Enable this API with the
--experimental-webstorage
CLI flag.
¥The
navigator.language
read-only property returns a string representing the
preferred language of the Node.js instance. The language will be determined by
the ICU library used by Node.js at runtime based on the
default language of the operating system.
¥The
queueMicrotask()
method queues a microtask to invoke
callback
. If
callback
throws an exception, the
process
object
'uncaughtException'
event will be emitted.
¥The microtask queue is managed by V8 and may be used in a similar manner to
the
process.nextTick()
queue, which is managed by Node.js. The
process.nextTick()
queue is always processed before the microtask queue
within each turn of the Node.js event loop.
// Here, `queueMicrotask()` is used to ensure the 'load' event is always// emitted asynchronously, and therefore consistently. Using// `process.nextTick()` here would result in the 'load' event always emitting// before any other promise jobs.DataHandler.prototype.load = asyncfunctionload(key) {
const hit = this._cache.get(key);
if (hit !== undefined) {
queueMicrotask(() => {
this.emit('load', hit);
return;
const data = awaitfetchData(key);
this._cache.set(key, data);
this.emit('load', data);
};
¥A browser-compatible implementation of
sessionStorage
. Data is stored in
memory, with a storage quota of 10 MB. Any modification of this data outside of
the Web Storage API is not supported. Enable this API with the
--experimental-webstorage
CLI flag.
¥A browser-compatible implementation of
<SubtleCrypto>
. This global is available
only if the Node.js binary was compiled with including support for the
node:crypto
module.