nodejs global variable across files code example
Example 1: node.js save global variable
global.number = 5;
Example 2: javascript global variable across files
var window.iAmGlobal = "some val"; //Global variable declaration with window.
//Any place in other part of code
function doSomething()
{
alert(window.iAmGlobal); //I am accessible here too !!
//OR
alert(iAmGlobal); //I am accessible here too !!
}
Example 3: set a variable in express.js
app.set('oneSetting', 'one');
app.set('twoSetting', 'two');
app.set('view engine','jade');
console.log(app.settings.oneSetting);
console.log(app.settings.twoSetting);
console.log(app.settings['view engine']);