Created
February 16, 2011 23:57
-
-
Save bmavity/830599 to your computer and use it in GitHub Desktop.
This file contains 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 ext = require('./sampleExternal'); | |
// In node.js, there is a global object called | |
// global (go figure) | |
console.log(global); // empty object | |
// This is defined in the external JavaScript file | |
// outside of a function, and with the var keyword | |
console.log(global.outsideFunctionWithVar); // undefined | |
console.log(ext.outsideFunctionWithVar); // undefined | |
// This is defined in the external JavaScript file | |
// inside of a function, and without the var keyword | |
console.log(global.insideFunctionWithoutVar); // 'hippo' | |
console.log(ext.insideFunctionWithoutVar); // undefined | |
// This is defined in the external JavaScript file | |
// inside of a function, and with the var keyword | |
console.log(global.insideFunctionWithVar); // undefined | |
console.log(ext.insideFunctionWithVar); // undefined | |
var thisFile = 'on it'; | |
console.log(global.thisFile); // undefined | |
console.log(thisFile); // 'on it' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment