function declaration vs function call conflict

function() { return count++; } is running because it is a function declaration. It is running and result of this running a function has been created and sent as a parameter to return command. "return count++;" this part is not running because the function has not been called yet.
This commit is contained in:
lumosmind 2019-10-29 21:33:42 +03:00 committed by GitHub
parent 7510263654
commit 97cd2fca8d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -351,7 +351,7 @@ Please note the additional `[[Environment]]` property is covered here. We didn't
![](lexenv-nested-makecounter-3.svg) ![](lexenv-nested-makecounter-3.svg)
Please note that on this step the inner function was created, but not yet called. The code inside `function() { return count++; }` is not running. Please note that on this step the inner function was created, but not yet called. The code inside `return count++;` is not running.
4. As the execution goes on, the call to `makeCounter()` finishes, and the result (the tiny nested function) is assigned to the global variable `counter`: 4. As the execution goes on, the call to `makeCounter()` finishes, and the result (the tiny nested function) is assigned to the global variable `counter`: