Node
References
env

env

Utility class for detecting the current environment where the code is running. Can detect if the code is running in a browser, node.js, JSDOM or a web worker.

Accessors

browser

Indicates whether the code is running in a browser environment.

Syntax

get browser(): boolean

Returns: true if running in a browser environment, false otherwise.

Examples

console.log(env.browser) // true or false

jsdom

Indicates whether the code is running in a JSDOM environment.

Syntax

get jsdom(): boolean

Returns: true if running in a JSDOM environment, false otherwise.

Examples

console.log(env.jsdom) // true or false

node

Indicates whether the code is running in a Node.js environment.

Syntax

get node(): boolean

Returns: true if running in a Node.js environment, false otherwise.

Examples

console.log(env.node) // true or false

worker

Indicates whether the code is running in a Node.js environment.

Syntax

get worker(): boolean

Returns: true if running in a Web Worker environment, false otherwise.

Examples

console.log(env.worker) // true or false