Hey guys I’m having an issue with this statement in Internet Explorer,
I was wondering if there is a saner way to do it?
var NEWVARIABLE = NEWVARIABLE || {};
NEWVARIABLE.Tools = NEWVARIABLE.Tools || {};
Its giving me the error that NEWVARIABLE does not exist
You’ve accepted an answer, but it contains a misleading statement:
The variable is declared, so it isn’t what you are doing.
In the OP, the code:
contains no syntax errors, the only case where it will throw an error is if NEWVARIABLE already exists and has a Tools property that throws an error when attempting to access or assign to it (as may happen with certain host objects).
If
NEWVARIABLEhas previously been assigned a native object or primitive value, it will not throw an error, though the result may not be what you expect.