Question: javascript runtime error 'x' is undefined?
Answer: In order for Javascript to compare the value of the x variable it must look it up; since it is not yet defined it throws an error message. This error is happening before the runtime even attempts to compare the value to undefined . ... use typeof x === 'undefined' instead.