P
petermichaux
Hi,
I have been using the following line of code to create an object called
"Serious" if it doesn't already exist.
if (Serious == null) {var Serious = {};}
This works in the scripts I use it but but www.jslint.com is not happy
with me.
Problem at line 1 character 16: Use '===' to compare with 'null'.
if (Serious == null) {var Serious = {};}
Problem at line 1 character 27: Var Serious was used before it
was declared.
if (Serious == null) {var Serious = {};}
Problem at line 1 character 27: Identifier 'Serious' already
declared as global
if (Serious == null) {var Serious = {};}
If I change to "===" then the condition is never true.
What is the correct way to create an empty object only if the object
does not exist?
Thanks,
Peter
I have been using the following line of code to create an object called
"Serious" if it doesn't already exist.
if (Serious == null) {var Serious = {};}
This works in the scripts I use it but but www.jslint.com is not happy
with me.
Problem at line 1 character 16: Use '===' to compare with 'null'.
if (Serious == null) {var Serious = {};}
Problem at line 1 character 27: Var Serious was used before it
was declared.
if (Serious == null) {var Serious = {};}
Problem at line 1 character 27: Identifier 'Serious' already
declared as global
if (Serious == null) {var Serious = {};}
If I change to "===" then the condition is never true.
What is the correct way to create an empty object only if the object
does not exist?
Thanks,
Peter