← Quiz: Scope, Closures, Hoisting and this: all 15 questions
Quiz: Scope, Closures, Hoisting and this · Question 10 of 15
What is a practical use of closures?
What is a practical use of closures?
- A.Making loops run faster
- B.Keeping private state, such as a wallet balance only changeable through its functions
- C.Declaring global variables
- D.Converting strings to numbers
Answer & explanation
Correct answer: Keeping private state, such as a wallet balance only changeable through its functions
The returned functions can reach the variable, but no other code can.
Can you get the rest right without peeking?
Take the timed Quiz: Scope, Closures, Hoisting and this quiz free. Pass it to earn XP and count towards your certificate.
Start the quiz →