在Objects as interfaces
的{{1}}部分中查看eloquentjavascript,有一个例子:
(在函数之外,这是指全局范围对象。)
(function(exports) {
var names = ["Sunday", "Monday", "Tuesday", "Wednesday",
"Thursday", "Friday", "Saturday"];
exports.name = function(number) {
return names[number];
};
exports.number = function(name) {
return names.indexOf(name);
};
})(this.weekDay = {});
console.log(weekDay.name(weekDay.number("Saturday")));
// → Saturday
this refers to the global scope object
是什么意思?这里的全局范围对象是什么(这个)?困惑。
欢迎任何评论。感谢