[Javascript] getGlobalThis()

let _globalThis: any
export const getGlobalThis = (): any => {
  return (
    _globalThis ||
    (_globalThis =
      typeof globalThis !== 'undefined'
        ? globalThis
        : typeof self !== 'undefined'
          ? self
          : typeof window !== 'undefined'
            ? window
            : typeof global !== 'undefined'
              ? global
              : {})
  )
}

 

posted @   Zhentiw  阅读(5)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 阿里最新开源QwQ-32B,效果媲美deepseek-r1满血版,部署成本又又又降低了!
· Manus重磅发布:全球首款通用AI代理技术深度解析与实战指南
· 开源Multi-agent AI智能体框架aevatar.ai,欢迎大家贡献代码
· 被坑几百块钱后,我竟然真的恢复了删除的微信聊天记录!
· AI技术革命,工作效率10个最佳AI工具
历史上的今天:
2022-12-02 [Typescript] 124. Binary to Decimal
2019-12-02 [CSS3] Use media query to split css files and Dark mode (prefers-color-scheme: dark)
2019-12-02 [PWA] Storage information for PWA application
2019-12-02 [HTML5] Native lazy-loading for the web
2019-12-02 [Dynamic Programming] 198. House Robber
2016-12-02 [D3] Create Labels from Non-numeric Data with Ordinal Scales in D3 v4
2016-12-02 [D3] Create Labels from Numeric Data with Quantize Scales in D3 v4
点击右上角即可分享
微信分享提示