kb/data/developer.mozilla.org/en-US/docs/Glossary/Global_object-0.md

12 KiB

title chunk source category tags date_saved instance
Global object - Glossary | MDN 1/3 https://developer.mozilla.org/en-US/docs/Glossary/Global_object reference web, html, css, javascript, documentation 2026-05-05T05:32:35.660821+00:00 kb-cron

MDN HTML HTML: Markup language

HTML reference

HTML guides

Markup languages

CSS CSS: Styling language

CSS reference

CSS guides

Layout cookbook

JavaScriptJS JavaScript: Scripting language

JS reference

JS guides

Web APIs Web APIs: Programming interfaces

Web API reference

Web API guides

All All web technology

Technologies

Topics

Learn Learn web development

Frontend developer course

Learn HTML

Learn CSS

Learn JavaScript

Tools Discover our tools

About Get to know MDN better

Blog

  1. Glossary
  2. Global object

Global object

The global object in JavaScript is an object which represents the global scope. Note: Globally available objects , which are objects in the global scope, are sometimes also referred to as global objects, but strictly speaking, there is only one global object per environment. In each JavaScript environment, there's always a global object defined. The global object's interface depends on the execution context in which the script is running. For example:

  • In a web browser, any code which the script doesn't specifically start up as a background task has a Window as its global object. This is the vast majority of JavaScript code on the Web.
  • Code running in a Worker has a WorkerGlobalScope object as its global object.
  • Scripts running under Node.js have an object called global as their global object.

The globalThis global property allows one to access the global object regardless of the current environment. var statements and function declarations at the top level of a script create properties of the global object. On the other hand, let and const declarations never create properties of the global object. The properties of the global object are automatically added to the global scope. In JavaScript, the global object always holds a reference to itself:

In this article

See also