Created
February 1, 2010 11:49
-
-
Save jimbojw/291635 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var sys = require('sys'); | |
sys.puts("Top level"); | |
sys.puts(" this === GLOBAL: " + (this === GLOBAL)); // false | |
sys.puts(" this === exports: " + (this === exports)); // true | |
var x = "1"; // local variable | |
sys.puts(" x === GLOBAL.x: " + (x === GLOBAL.x)); // false | |
sys.puts(" x === exports.x: " + (x === exports.x)); // false | |
this.y = "2"; // property of this | |
sys.puts(" this.y === GLOBAL.y: " + (this.y === GLOBAL.y)); // false | |
sys.puts(" this.y === exports.y: " + (this.y === exports.y)); // true | |
(function(){ // anonymous function | |
sys.puts("Inside function"); | |
sys.puts(" this === GLOBAL: " + (this === GLOBAL)); // true | |
sys.puts(" this === exports: " + (this === exports)); // false | |
this.z = "3"; // property of this | |
sys.puts(" this.z === GLOBAL.z: " + (this.z === GLOBAL.z)); // true | |
sys.puts(" this.z === exports.z: " + (this.z === exports.z)); // false | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment