How does closure work in function expressions passed as parameters?
问题 A thing about closure . In these two snippets below I'm passing a function expression as a callback. (In the first snippet) When calling back the function expression, I expect to see the anonymous function to close over def , but when I call second() instead of looking inside its "closure" for the variable first (where first is updatedValue ), search and find first in the global variable environment, where first has the value oldValue . function def(first="oldValue" , second=function(){