Global variables declared with var at the global scope in a browser become properties of which object?

Prepare for the uCertify CIW Advanced HTML5 and CSS3 Specialist Exam. Dive into essential topics with flashcards and multiple-choice questions. Enhance your understanding with hints and explanations for each question. Pass your exam confidently!

Multiple Choice

Global variables declared with var at the global scope in a browser become properties of which object?

Global variables declared with var at the global scope in a browser become properties of the window object. The window object is the browser’s global container, so a top-level var creates a property on window, accessible as window.myVar and as myVar in the global scope. This behavior is specific to var; top-level let or const do not create properties on window. The other options—document (the DOM), location (the page URL information), and console (the debugging interface)—are separate browser APIs and not where global var declarations attach.

Subscribe

Get the latest from Examzify

You can unsubscribe at any time. Read our privacy policy