Recall & Review
beginner
What is module scope in JavaScript?
Module scope means variables and functions declared inside a module are only accessible within that module, not outside it.
Click to reveal answer
beginner
How do you create a module in JavaScript?
You create a module by saving code in a separate file and using
import and export statements to share parts of it.Click to reveal answer
beginner
What happens if you declare a variable inside a module without exporting it?
That variable stays private to the module and cannot be accessed from other modules.
Click to reveal answer
beginner
Why is module scope useful?
It helps keep code organized and avoids name conflicts by hiding variables and functions inside modules.
Click to reveal answer
beginner
How do you export a function from a module?
Use <code>export function myFunc() {}</code> or <code>export { myFunc }</code> to make it available outside the module.Click to reveal answer
What does module scope restrict?
✗ Incorrect
Module scope restricts access to variables and functions declared inside the module from outside it.
Which keyword is used to share code from a module?
✗ Incorrect
The
export keyword shares code from a module so other modules can import it.If a variable is not exported, can other modules use it?
✗ Incorrect
Variables not exported remain private to their module and cannot be accessed from outside.
How do you import a function named
foo from a module?✗ Incorrect
Use
import foo from './module.js'; to import the default exported function foo.What is a benefit of module scope?
✗ Incorrect
Module scope hides variables and functions inside modules to avoid name conflicts and keep code organized.
Explain what module scope is and why it is important in JavaScript.
Think about how modules keep code separate and private.
You got /4 concepts.
Describe how you share and use code between JavaScript modules.
Focus on how to make code available outside a module.
You got /4 concepts.