Trying to access undefined variable in Javascript gives ReferenceError. typeof is working because it not accessing variable value. Its checking its type.
typeof not requires defined variable. Its parameter should be an expression representing the object or primitive whose type is to be returned.