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

Popular posts from this blog

java - SSE Emitter : Manage timeouts and complete() -

jquery - uncaught exception: DataTables Editor - remote hosting of code not allowed -

java - How to resolve error - package com.squareup.okhttp3 doesn't exist? -