I apologize in advance for yet another closure question, but I\'d like to clarify my understanding of the way closures are implemented in JavaScript.
Consider the fo
Does this sound about right?
Pretty much. I just wouldn't use the work "copied", rather "linked". To simplify it a little:
Or in pictures:
+----------------+ +----------------+
Function | | [[Environment]] | Outer |
creation | Function |-------------------->| Environment |
| | | |
+----------------+ +----------------+
^
|
|
+----------------+ |
Function | Function | outer environment reference |
execution | Environment |------------------------------+
| |
+----------------+
This happens to every function and depending on your definition of closure1, this makes every function a closure (or not).
1: I believe there are these two takes on what it means for a function to be a closure: