1.
var output = 0;(function() { output+ +;} ()); Console.log (output);
The function operates on global output because JS does not have a block-level scope, so output is 1.
2.
var output = 0;(function(output) { output+ +;} (output)); Console.log (output);
The function passes in the output value, but the function only adds an operation to the parameter output and does not operate on the global output, so output is 0.
3.
var output = 0;(function() { output+ +;} (output)); Console.log (output);
The output value within the function is not used by the function itself, and is not passed through the parameter, so the global output is added with an output of 1.
4.
var output = 0;(function() {//A var output = 0; (function() {//B output++; } ());} ()); Console.log (output);
The output of function B is an operation that operates on output in the A function, has no effect on the global output, and output is 0.
5.
var output = 0;(function() {//A (function() {/ / B output++; }()); var output = 0;} ()); Console.log (output);
Output in B cannot get global output, so the output plus one operation is not valid. So the output is 0.
6.
var output = 0;(function() {//A (function() {/ / B output++; } (output));} ()); Console.log (output);
Performs an output plus operation in the global, so the output is 1.
6 function output See the block-level scope of JS