> From: Matt Zagrabelny > > My main question is how does both the 'if' block and the > 'else' block get executed in the same pass through the function?
I haven't been following the thread in detail, but the simple answer to that question is they don't, and they can't. Fundamental JavaScript operations are reliable. It would take a major breakdown of the JavaScript interpreter to get both an "if" and associated "else" block to execute in the same pass through the code. If it looks like that is happening, it's a safe bet that the problem is really something else. If you're not sure about something like this, add console.log calls to trace through the code: console.log( 'before if/else statement' ); if( condition ) { console.log( 'inside if statement' ); } else { console.log( 'inside else statement' ); } console.log( 'after if/else statement' ); When you run that code, you will always see this sequence: before if/else statement inside if statement after if/else statement Or this one: before if/else statement inside else statement after if/else statement You will *never* see this: before if/else statement inside if statement inside else statement after if/else statement It just won't happen. -Mike