You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
})();
// bottom of the file
The effect is to insert a new, empty environment in between the global environment and your own functions: {x: 1, '..': {'..': global environment}}
Why is this true? Also, there is no argument to the function, so x: 1 is confusing. Previously you wrote "The environment for (function (y) { return x })(2) is actually {y: 2, '..': {x: 1, ...}}". If we changed the underlying example for this to:
(function () {
return function (y) {
return x
}
})(2)()
After taking out the parameters/arguments for the outer function, the environment for the closure is {y: 2, '..': {'..': global environment}}. This environment has the same structure as the first example, but the structure of the code is quite different.
The text was updated successfully, but these errors were encountered:
// top of the file
(function () {
// ... lots of JavaScript ...
})();
// bottom of the file
The effect is to insert a new, empty environment in between the global environment and your own functions: {x: 1, '..': {'..': global environment}}
Why is this true? Also, there is no argument to the function, so x: 1 is confusing. Previously you wrote "The environment for (function (y) { return x })(2) is actually {y: 2, '..': {x: 1, ...}}". If we changed the underlying example for this to:
(function () {
return function (y) {
return x
}
})(2)()
After taking out the parameters/arguments for the outer function, the environment for the closure is {y: 2, '..': {'..': global environment}}. This environment has the same structure as the first example, but the structure of the code is quite different.
The text was updated successfully, but these errors were encountered: