Let I have a simple code
{
let i = 10;
function outer() {
let j = 20;
console.log(i, j);
}
let inner = outer();
}
And the output is
10 20
which is obvious. But I thought I only stored the function value in inner, but never called it. Then why is it logging the output to the console?
inneris equal to the return value of yourouterfunction:undefined. If you want to copy the reference to your function, you’d uselet inner = outer;instead.