Use typeof to check undefined variable