console.log("0");
var name = "The Window";
console.log("1");
var object = {
name: "My Object",
getNameFunc: function () {
return function () {
console.log(this.name);
return this.name;
};
}
};
console.log("3");
console.log(object.getNameFunc()());
}这是原代码地址:https://www.w3cschool.cn/jsnote/jsnote-closure.html下面是我自己运行的代码function JSPfunction003() {
console.log("0");
var name = "The Window";
console.log("1");
var object = {
name: "My Object",
getNameFunc: function () {
return function () {
console.log(this.name);
return this.name;
};
}
};
console.log("3");
console.log(object.getNameFunc()());
}
添加回答
举报
0/150
提交
取消