When node runs your file, it is processed as a module, and the documents say it is effectively wrapped:
(function (exports, require, module, __filename, __dirname) {
// Your module code actually lives in here
});
, var id = "not awesome";
.
, this
. , var id
, , node undefined
.
, :
(function() {
'use strict'
var obj = {
id: "awesome",
cool: function coolFn() {
console.log(this.id);
}
};
var id = "not awesome";
obj.cool();
setTimeout(obj.cool, 100);
})();