No. Only var declarations at the top level become properties of window. let, const, and class declarations live in a separate global lexical environment and do not attach to window.
The window Object in JavaScript Explained
Do let and const become properties of window in JavaScript?
The answer
More FAQs in The window Object in JavaScript Explained
It is the global object in browsers. It represents the browser tab and holds global variables (from var), built-in APIs (console, setTimeout, fetch), the DOM (document), and UI methods (alert, prompt).
window is the global object representing the browser tab. document is the parsed HTML page inside that tab, accessible as window.document. window holds APIs and globals; document holds the DOM tree.
Use ES modules (import/export) to keep declarations out of window. Use IIFes in script files to contain var. Avoid var at the top level; prefer let and const.
Still have questions?
Browse all our FAQs or reach out to our support team
Want to upskill yourself?
Your learning library
Small steps. Big possibilities.
Find your next course. Build something great.