【发布时间】:2021-05-30 11:39:55
【问题描述】:
为什么将错误代码行放在底部,运行程序的其余部分。但是放在这里不会运行任何单个函数,会导致错误。
const A = "A";
let F;
function doStuff(B) {
console.log(B);
const C = "C";
let H = "H";
if (1 + 1 === 2) {
const D = "D";
H = "something else";
}
console.log(H);
F = "F";
}
console.log(B); // I know it has error
let E = 0;
while (E < 3) {
E++;
console.log(A); //But why this
}
doStuff("B"); // and this
console.log(E); // and this is not working unless I remove that line or place that in the bottom of the code.
【问题讨论】:
-
我知道它有错误,然后修复它,因为这是问题
-
听起来你需要研究Javascript scope
标签: javascript node.js reactjs