What does the call stack look like in a system of nested functions, functions passed as arguments, and returned functions?
问题 Here is a made up example of nested functions with functions passed as parameters and functions returned: function foo() { let x = 100 function bar(a, b) { function mul(cb) { let m = x * a cb(m) } function add(cb) { let m = x + b cb(m) } function update(m) { x = m } mul(update) add(update) console.log(x) } return bar } let bar = foo() bar(2, 3) // => 203 bar(2, 3) // => 409 bar(2, 3) // => 821 bar(2, 3) // => 1645 Without figuring out potential ways in which these functions could be optimized