js函数尾调用优化

为什么在chrome调试的时候还是三个函数都在栈中?符合函数尾调用,这个时候栈中不应该只有 foo的调用吗?

"use strict";

function foo() {
 const e = 5;
 const f = 6;
 console.log(111);
}

function bar() {
 const c = 3;
 const d = 4;
 return foo();
}

function baz() {
 console.log(arguments);
 const a = 1;
 const b = 2;
 return bar(a, b);
}

debugger;

baz();

image.png

阅读 1.4k
1 个回答
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题