Recall & Review
beginner
What is global scope in JavaScript?
Global scope means a variable or function is accessible from anywhere in the code, no matter where it is used.
Click to reveal answer
beginner
Where are variables declared outside any function or block stored?
They are stored in the global scope and can be accessed anywhere in the program.
Click to reveal answer
intermediate
What happens if you declare a variable without
let, const, or var inside a function?It becomes a global variable, which can cause bugs because it is accessible everywhere.
Click to reveal answer
beginner
How can you avoid polluting the global scope?
Use
let, const, or var inside functions or blocks to keep variables local.Click to reveal answer
intermediate
What is the global object in browsers and how is it related to global scope?
In browsers, the global object is
window. Variables in global scope become properties of window.Click to reveal answer
Where can you access a variable declared in the global scope?
✗ Incorrect
Variables declared in the global scope are accessible anywhere in the program.
What happens if you forget to use
let, const, or var when declaring a variable inside a function?✗ Incorrect
Without declaration keywords, the variable is created in the global scope, which can cause bugs.
Which object represents the global scope in a browser environment?
✗ Incorrect
The
window object is the global object in browsers, holding global variables and functions.How can you keep variables from polluting the global scope?
✗ Incorrect
Using
let or const inside functions or blocks keeps variables local and avoids global pollution.Which of these is true about global scope?
✗ Incorrect
Global scope variables are accessible from any part of the code.
Explain what global scope means in JavaScript and why it can be risky to use too many global variables.
Think about how variables can be seen everywhere and how that might cause problems.
You got /4 concepts.
Describe how to avoid polluting the global scope when writing JavaScript code.
Focus on how to keep variables limited to where they are needed.
You got /4 concepts.