Looking into eloquentjavascript, in the section of Objects as interfaces
, there is an example:
(Outside of a function, this refers to the global scope object.)
(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
What does this refers to the global scope object
mean? what is the global scope object here (this)? Confused.
Any comments welcomed. Thanks