QuestenaUn entraînement qui indique quoi revoir ensuite
Question 84

A factory call creates a local count binding and returns an inner function that reads count. The factory call has finished. Why can the inner function still read count?

  1. All local bindings automatically become global
  2. The factory call remains permanently active on the call stack
  3. The caller recreates count before every inner call
  4. The inner function retains its creation scope through a closureBonne réponse

Explication

The returned inner function closes over the lexical environment in which it was created, retaining access to count after the factory call ends. The caller's current local variables do not replace that environment, because this access is lexical rather than caller-based.

Continuer avec ce test

Commencer l’entraînement
Question 84: A factory call creates a local count binding and returns an… · JavaScript Fundamentals · Questena