Can someone explain reasons for putting all variables with application scope vs. window scope? Is application scope ALWAYS better?
- performance?
- prevent naming collisons?
- other reasons?
window scope
var myFunction1=function(){
//do something
};
var myFunction2=function(){
//do something else
};
var myObject1={
//store stuff
};
var myDOMElement1=$('.myDOMElement1');
application scope
var myApplication={
'myFunction1':function(){
//do something
},
'myFunction2':function(){
//do something else
},
'myObject1':{
//store stuff
},
'myDOMElement1':$('.myDOMElement1')
};