| [ Web Proxy ] |
| Viewing: https://developer.mozilla.org/ru/docs/Web/JavaScript/Reference/Global_Objects/globalThis | [Back] [Original] |
Get to know MDN better
This page was translated from English by the community. Learn more and join the MDN Web Docs community.
This feature is well established and works across many devices and browser versions. Its been available across browsers since 2020 ..
globalThis this, .
function canMakeHTTPRequest() {
return typeof globalThis.XMLHttpRequest === "function";
}
console.log(canMakeHTTPRequest());
// Expected output (in a browser): true
globalThis
, JavaScript. window, self frames, Worker self. Node.js , global.
this . this undefined. Function('return this')(), , eval(), CSP , Function .
globalThis this ( , ) . , window self, , window, , . . , , this globalThis.
globalThis , - - iframe cross-window Proxy ( ). , .
globalThis - Function('return this')(). , CSP . , es6-shim :
var getGlobal = function () {
if (typeof self !== "undefined") {
return self;
}
if (typeof window !== "undefined") {
return window;
}
if (typeof global !== "undefined") {
return global;
}
throw new Error("unable to locate global object");
};
var globals = getGlobal();
if (typeof globals.setTimeout !== "function") {
// setTimeout!
}
globalThis :
if (typeof globalThis.setTimeout !== "function") {
// setTimeout!
}
| Specification |
|---|
| ECMAScript 2027 LanguageSpecification # sec-globalthis |
This page was last modified on 29 . 2026 . by MDN contributors.
Your blueprint for a better internet.
Portions of this content are 19982026 by individual mozilla.org contributors. Content available under a Creative Commons license.
| Web Proxy Viewer | New URL | Original Page |