Question 15
Back to Exercise
Which is the best way to keep helper variables out of the global scope in modern code?
- A Declare everything with var
- B Put the code in an ES module (or at least inside a function or block) Correct
- C Prefix all names with g_
- D Store them as properties of window
Correct Answer: Option B
Modules give every file its own scope. In older code an IIFE did the same job.
Discussion & Comments 0
Share your method, a shortcut, or ask about a step you didn't follow.
No comments yet. Be the first to share your solution!