调用位置和绑定规则
1. 调用位置:寻找调用位置最重要的是分析调用栈(为了到达当前执行位置所调用的所有函数)。我们关心的调用位置就在当前正在执行的函数的前一个调用中。
function first() {
//当前调用栈是: first
//因此,当前调用位置是全局作用域
console.log("first") ;
second(); //<-- second 的调用位置
}
function second() {
//当前调用位置是 first -> second
// 因此,当前调用位置在 first 中
console.log('second');
third(); // third调用位置
}
function third() {
//当前调用位置在 first -> second -> third
// 当前调用位置在 second 中
console.log("third");
}
first(); // first调用位置2. 绑定规则:
Last updated