javascript window.onload scope

Posted by teggy on Stack Overflow See other posts from Stack Overflow or by teggy
Published on 2010-05-04T01:02:28Z Indexed on 2010/05/04 1:08 UTC
Read the original article Hit count: 223

Filed under:
|

Can someone explain why the alert returns "undefined" instead of "hello"?

window.onload = function() {  
    var a = 'hello';  
    alert(window.a);  
}

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about variable-scope