JavaScript Closure Example
References: What are closures? and Memory Leakage in Internet Explorer - revisited
The variable y was saved as a property of the function objects.
But when we use the functions, they do add the value of y they were originally called with.
What's Going On?
When MyFuncAddsFive was created by AdderFactory, it was given a value of 5. So when we later call MyFuncAddsFive(123) with a value of 123, it adds 123 + 5 (x + y). We see the same for MyFuncAddsTen, which adds 0 + 10 (x + y). Where is the value of y coming from? It is not a property of the function objects, because when we write out MyFuncAddsFive.y and MyFuncAddsTen.y they are undefined.