Javascript keeps undefining my vars, it's harshing my buzz. Help?
        Posted  
        
            by Keene Maverick
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by Keene Maverick
        
        
        
        Published on 2010-03-19T20:11:44Z
        Indexed on 
            2010/03/19
            20:21 UTC
        
        
        Read the original article
        Hit count: 189
        
JavaScript
This is my first experience with javascript, and... Well... Ugh. Here's what's happening:
function step_1(id) {
    //blah blah
    step_2(id);
}
function step_2(id) {
    //blah blah
    step_3(id);
}
function step_3(id) {
    //blah blah
    alert(id);
}
step_1(0); // I can stick any number here, same thing happens...
The alert pops up and says "Undefined". But, if I throw an alert(id); in step_2, then both alerts say "0".
Why/how is id undefined? What am I doing wrong?
I've even tried reassigning id in each function, like:
var nid = id;
step_2(nid);
etc... But that still doesn't work without the alerts.
© Stack Overflow or respective owner