Hi
It is good practice to create one unique global object that wrap the functions and properties inside this object.I look up a lot of sample code and see code like this
if(!myglobalObject) myglobalObject ={};
However , this code does not work ,I got an error saying
ReferenceError: myglobalObject is not defined
Can anyone shed some light on why I got the error?
To avoid errors in ECMAScript 5 strict mode, you need to use
varto define all variables:The other alternative is to assign a property to the global object: