时间:2021-07-01 10:21:17 帮助过:4人阅读
输出"local"
/* 代码1 */
var scope = "global ";
function checkScope() {
var scope = "local ";
function childCheck() {
var scope = "childLocal ";
document.write(scope);
}
function childUndefined() {
document.write(scope);
var scope;
}
function childOverride() {
scope = "childOverride ";
document.write(scope);
}
document.write(scope); //
输出"local"
/* 代码2 */
var scope = "global";
function checkScope() {
var scope = "local";
document.write(scope);
}
checkScope(); //
输出"local"
/* 代码3 */
var scope = "global";
function checkScope() {
scope = "local";
document.write(scope);
}
checkScope(); //
输出"undefinedlocal"
/* 代码4 */
var scope = "global";
function checkScope() {
document.write(scope); //语句4.1
var scope = "local"; //语句4.2
document.write(scope);
}
checkScope(); //
输出"loacl"
/* 代码5 */
var scope = "global ";
var obj = new Object();
obj.scope = "object ";
obj.checkScope = function () {
var scope = "loacl ";
document.write(scope); //