GlobalThis
The globalThis global object.
Properties
| Property | Type | Description |
|---|---|---|
Encode string text into bytes array, it only supports "utf-8" encoding. | ||
Decode bytes array into string text, with specified encoding. |
Methods
clearInterval()
clearInterval(id): void;
Cancel a repeated timer previously established by calling setInterval.
Parameters
| Parameter | Type | Description |
|---|---|---|
|
| 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
| Parameter | Type | Description |
|---|---|---|
|
| 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
| Parameter | Type | Description |
|---|---|---|
| () => | 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
| Parameter | Type | Description |
|---|---|---|
|
| 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
| Parameter | Type | Description |
|---|---|---|
| (... | A function to be executed every |
|
| (Optional) The milliseconds that the timer should delay in between execution of the function, by default is |
... |
| (Optional) 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
| Parameter | Type | Description |
|---|---|---|
| (... | A function to be executed after the timer expires. |
|
| (Optional) The milliseconds that the timer should wait before the function is executed, by default is |
... |
| (Optional) 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.