Eloquent Javascript: what is `this` in the following example? -
looking eloquentjavascript, in section of objects interfaces
, there example:
(outside of function, this refers 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 this refers global scope object
mean? global scope object here (this)? confused.
any comments welcomed. thanks
Comments
Post a Comment