Like you would do in php:
if (@$some_var_exists) // do stuff
How would you do something like this in Javascript without getting an error?
Thanks
EDIT: Thanks for the answers. However, the problem I’m trying to solve is how to check if a variable exists when it’s deep in a object, for example:
if (someObj.something.foo.bar) // This gives an error in the browser if 'someObj.something.foo' is not defined.
Check each part of the chain:
Because the expression is evaluated from left to right, and returns as soon as it finds false, it will not cause an error. So if ‘someObj’ exists, but ‘sometObj.something’ does not, it will return false and never execute the test for someObj.something.foo that would throw an error.