<html>
<body>
<script type= "text/javascript">
var i=10;
function f(){
alert(i);
if(!i){
var i= 20;
}
alert(i);
}
f();
</script>
</body>
</html>
This is my html file. The outputs I get are undefined for first alert and 20 for the second alert. Why is this so? What is happening here?