🎙 Free live masterclass · Sun, 29 Nov, 7:00 pm IST · Java Full Stack roadmap Register free →
Skills101
← 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?

  1. A.Making loops run faster
  2. B.Keeping private state, such as a wallet balance only changeable through its functions
  3. C.Declaring global variables
  4. 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 →