JsLint 'out of scope' error

Posted by Rajat on Stack Overflow See other posts from Stack Overflow or by Rajat
Published on 2010-03-20T23:14:53Z Indexed on 2010/03/20 23:21 UTC
Read the original article Hit count: 694

Filed under:
|
function test(){
    if(true){
        var a = 5;
    }
    alert(a);
}

test();

I keep getting 'out of scope' errors in my JS code when I check with JsLint which make no sense to me.So I quickly created an example. Is there something actually wrong with this code piece, as the variable is eventually hoisted to the top of the function anyways.

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about jslint