Very good question about scope. For those that don't know, scope is the context a variable can be used.
Each mapping function is wrapped in its own JavaScript function. This means that any variable declared in the mapping function can be used only within the context or scope of the function. Feel free to reuse the name in a different mapping function~ it will be a new variable.
There are some declared and initialized JavaScript variables which are included in the scope of QIE scripts. These would be the QIE specific objects found in the Code Wizard like messageCache, channelCache, source, message, qie, StringUtils, etc. The key names in the caches do not effect variables with the same name.
// myValue is a local variable and is not related to messageCache values.
// these are two separate variables and values.
var myValue = 'blue';
messageCache.setValue('myValue', 'red');
QIE System Variables are accessed with qie.setVariable() and qie.getVariable(). Although System Variables cannot have duplicate names, you may name any local variable or cache name the same. QIE System Variables can be in a specific zone or be in the global zone, but they will have the same behavior.
// No variable conflict
var myValue = 'Some value';
var otherValue = qie.getVariable('myValue');
QIE uses JavaScript, so it will follow the scope defined by the Javascript standards. (See http://stackoverflow.com/questions/500431/what-is-the-scope-of-variables-in-javascript for some examples). A global JavaScript variable will actually pass out of scope when the mapping node completes. However, you should use messageCache.setValue() and messageCache.getValue() to persist and retrieve a value from one mapping function to the next.