alert(f !== undefined )
<script> alert(typeof f != 'undefined' ) var f=1; alert(typeof f != 'undefined' ); </script>