Possible Duplicate:
How to distinguish between a variable that is not declared and a varrable that is declared but not be assigned any value?
I want to see in my code whether someone in the past has already declared the a variable.
I thought about this:
alert(typeof(a)=="undefined") //true
but then I tested:
var a;
alert(typeof(a)=="undefined") //also true !
so how can I check whether there was var a somewhere in the past?
The only way to check whether a variable is (locally) declared is to test the value, and see if any
ReferenceErroris thrown.