You are not passing setTimeout
the function d
in the second example; you are instead passing d()
, which is the result of calling d
.
The result of calling d
is undefined
since it returns nothing, which converts to the string "undefined"
, which is then eval
ed, doing... precisely nothing.
With regard to callstacks, since you are calling d
inside of c
, that is why you see c
in the callstack. To clarify, your second example is the same as
function c() {
var temp = d();
setTimeout(temp, 1000);
}
function d() {
debugger;
}
c();
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…