Etiquetas

Assume that we have the following short JavaScript code: <script>
var y = 10;
if (!(x in window)) {
var x = 10;
} else {
++y;
}
alert(x);
alert(y);
</script>
Will this code succeed or fail? and if it succeeds, what is the output of the alerts? Read the complete answer

Sometimes, the Java developers that are new to the JavaScript world have a confusion regarding the variable scoping in JavaScript. This post resolves this confusion: http://www.technicaladvices.com/2013/02/15/checking-the-local-storage-limits-across-the-browsers/