Why is the following line not alerted?
<script>
alert(x);//this line is not executed or alerted ???.It should have alerted "undefined"
console.log(x)//reference error
var y="maizere";
alert(y);//this line is also not executed or alerted ???
</script>
Any undeclared variables are treated as global variable in javascript right?
That’s incorrect. This line raises a
ReferenceErrorbecause there’s no variablex.Contrast this with situation: