JS: Proper Global Variables
It's not a good idea to use global variables but if you do, this technique is probably the safest.
// Global Object #1. Type: Object.
function setData( d ) {
var data = d;
getData = function() {
return data;
}
}
// Global Object #2. Type: String.
function setSection( d ){
var data = d;
getSection = function(){
return data;
}
}
Now all you need to do is access it.
// Set your data
setData(YOUR_DATA)
// Get your data
getData()['key']