from:
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Functions
(about 40% down the page)
function foo(i) {
if (i < 0)
return;
console.log(‘begin:’ + i);
foo(i - 1);
console.log(‘end:’ + i);
}
foo(3);
// Output:
// begin:3
// begin:2
// begin:1
// begin:0
// end:0
// end:1
// end:2
// end:3
I follow all the way to end:0 output but can’t understand how it goes to end:1, etc…Any help here? Thanks in advance.