Learn Create Your Own Split Screen

Next Page

Were you right?

The use of var in both declarations means we have a 'thing' defined with global scope, and other 'thing' defined with local scope.

When do_something_else executes, the 'thing' that gets set to 100 is the local thing, because a 'thing' has been declared within the local scope of do_something_else.

After do_something_else finishes, we're back in the global scope, and the global 'thing' still has the value 12.


Imagine your name is Beyoncé and someone walks into your house and asks for Beyoncé's autograph. They'll get your autograph. Later, they walk into MTV and ask for Beyoncé's autograph and (maybe) they'll get a completely different autograph.

Same name. Different person due to different context.

In our example, there's two "thing's". Which one you're dealing with depends on the context.