Eloquent Javascript:以下示例中的“this”是什么?

时间:2016-11-05 15:43:35

标签: javascript javascript-objects

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是什么意思?这里的全局范围对象是什么(这个)?困惑。

欢迎任何评论。感谢

0 个答案:

没有答案