The scope attribute is determined when the function is defined, not when the function is called.
Functions in JavaScript run in the scope in which they are defined, not the scope in which they are executed.
eg.
var name = "lw"; function alert_1 () { alert(name); } function alert_2 () { var name = "zgm"; alert_1(); } alert_2();// 结果:lw
Functions in JavaScript run in the scope in which they are defined, not the scope in which they are executed.
Guess you like
Origin http://43.154.161.224:23101/article/api/json?id=324941164&siteId=291194637
Recommended
Ranking