在node.js模块和函数中“this”的含义
require
.
// loaded by require()var a = this; // "this" is an empty objectthis.anObject = {name:"An object"};var aFunction = function() { var innerThis = this; // "this" is node global object};aFunction();(function(anyParameter){ console.log(anyParameter.anObject);})( this // "this" is same having anObject. Not "global");
this
a = this;
this
this
this
this
global
this
相关分类