Sobes.tech
Middle+

/* What will be output in the console */ let value = 2; function showValue() { console.log(value); } function wrapper() { let value = 3; console.log(value); showValue(); } wrapper();

sobes.tech AI

Answer from AI

The console will output:

3
2

Explanation:

  • In the wrapper function, a local variable value is declared with the value 3, and it is immediately logged to the console — this is the first line of output.
  • Then, the showValue function is called, which accesses the variable value. Since there is no local variable value inside showValue, it looks for it in the outer scope — the global scope, where value equals 2.

Thus, first 3 is output, then 2.

/* What will be output in the console */ let value =… - sobes.tech