Skip to content

Function: getGlobal() ​

ts
function getGlobal(): unknown;

Returns the global object for the current runtime environment. 返回当前运行时环境的全局对象。

Returns ​

unknown

The global object (window, self, global, or globalThis) / 全局对象

Throws ​

Error if the global object cannot be located / 如果无法定位全局对象则抛出错误

Example ​

typescript
const g = getGlobal()
typeof g // => 'object'
g === globalThis // => true

Since ​

1.0.0

Released under the MIT License.