Skip to main content
Version: Next

GlobalThis

The globalThis global object.

Methods

clearInterval()

clearInterval(id): void;

Cancel a repeated timer previously established by calling setInterval.

Parameters

ParameterTypeDescription

id

number

The ID (integer) which identifies the schedule.

Returns

void

Throws

Throws TypeError if ID is not an integer.


clearTimeout()

clearTimeout(id): void;

Cancel a timeout previously established by calling setTimeout.

Parameters

ParameterTypeDescription

id

number

The ID (integer) which identifies the timer.

Returns

void

Throws

Throws TypeError if ID is not an integer.


queueMicrotask()

queueMicrotask(callback): void;

A microtask is a short function which is executed after the function or module which created it exits and only if the JavaScript execution stack is empty, but before returning control to the event loop being used to drive the script's execution environment.

Parameters

ParameterTypeDescription

callback

() => void

A function to be executed.

Returns

void

Throws

Throws TypeError if callback is not a function.


reportError()

reportError(error): void;

Dispatch an uncaught exception. Similar to synchronous version of setTimeout(() => {throw error;}, 0);.

Parameters

ParameterTypeDescription

error

any

Anything to be thrown.

Returns

void


setInterval()

setInterval(
callback,
delay?, ...
args?): number;

Set a repeated timer that calls a function, with a fixed time delay between each call.

Parameters

ParameterTypeDescription

callback

(...args) => void

A function to be executed every delay milliseconds.

delay?

number

The milliseconds that the timer should delay in between execution of the function. This parameter can be omitted, by default is 1.

...args?

any[]

Additional arguments which are passed through to the function.

Returns

number

The ID (integer) which identifies the timer created.

Throws

Throws TypeError if callback is not a function, or delay is neither a number or undefined.


setTimeout()

setTimeout(
callback,
delay?, ...
args?): number;

Set a timer which executes a function or specified piece of code once the timer expires.

Parameters

ParameterTypeDescription

callback

(...args) => void

A function to be executed after the timer expires.

delay?

number

The milliseconds that the timer should wait before the function is executed. This parameter can be omitted, by default is 1.

...args?

any[]

Additional arguments which are passed through to the function.

Returns

number

The ID (integer) which identifies the timer created.

Throws

Throws TypeError if callback is not a function, or delay is neither a number or undefined.