Skip to content

Instantly share code, notes, and snippets.

@eiriklv
Forked from soyuka/global.js
Last active August 29, 2015 14:07
Show Gist options
  • Save eiriklv/15fdc4693da744f3c4ae to your computer and use it in GitHub Desktop.
Save eiriklv/15fdc4693da744f3c4ae to your computer and use it in GitHub Desktop.
//global variable
test = 'hello';
//is exactly the same as
global.test = 'hello';
//local variable - this will definitly override your global variable
var test = 'world';
//using the process scope, if, and really if, you can't do without a global variable
process.test = 'world';
//Now both will be defined and using `process` will avoid any confusion
console.log(test + process.test);
//hello world
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment