What’s a JavaScript closure? In plain English, please.
Samer Buna
1.7K16

hey , i need to list a few pointers :

  1. first of all , you got confused with lexical scope rules and closures . closures are due to lexical scopes . if there not had been lexical scope , no closures would have been created.
  2. lexical scope is author time decision . A scope is created at compilation, not at execution . That would have been dynamic scope if that had been the case .
  3. a closure is a function that remembers it lexical scope if it’s executing outside its scope. you can access variables A,B,G because of lexical scope rules not closures . the function is not even executing outside its lexical scope.
  4. kyle simpson would have disagreed with this article .
One clap, two clap, three clap, forty?

By clapping more or less, you can signal to us which stories really stand out.