Here's our example again:
var thing = 12;
do_something_else();
alert("global thing=" + thing);
function do_something_else () {
var thing = 100;
alert("do_something_else's thing=" + thing);
}
First, we need to be
really clear that the alert inside the
do_something_else function will get executed
before the other alert. It's simply because do_something_else() gets called before the alert on the third line.
But what will be displayed?
The answer may or may not surprise you. See if you can figure it out, then click Next to see.