Does JavaScript have block scope?

Posted by piemesons on Stack Overflow See other posts from Stack Overflow or by piemesons
Published on 2010-04-06T11:04:46Z Indexed on 2010/04/06 11:13 UTC
Read the original article Hit count: 156

Filed under:
|
<html>
<body>
    <script type="text/javascript">
        var x = 13;
        {
            var x = 22;
        }
        alert(x);
    </script>
</body>
</html>

The output is 22. Why?

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about variable-scope