var a;
typeof(a);
//undefined
typeof(c);
//undefined
if(c) {}
//throw error
How can I know that c
doesn't exist without try
catch
.
Update after marked duplicate:
typeof initializedVariable
and typeof notInitializedVariable
both will show 'undefined'. My question is to know whether the variable exists(initialized) or not.