Why is the global variable some_var changed inside the if block in this example?
<script>
    var some_var = 0;
    var i = 5;
    if (i>2)
    {
        var some_var = 2;
    }
    else
    {}
    console.log(some_var);
</script>
Why is the global variable some_var changed inside the if block in this example?
<script>
    var some_var = 0;
    var i = 5;
    if (i>2)
    {
        var some_var = 2;
    }
    else
    {}
    console.log(some_var);
</script>
I'm guessing that if you remove the 'var' inside the if block it works properly. Must be the environment checking for initializations before running the code.
