JavaScript Quiz #10

November 2, 2013 in JavaScript

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

Comments are closed.

Skip to toolbar