Please assume the following contrived JavaScript:
function do_something() {
var x = 5;
function alert_x() {
alert(x);
}
alert_x();
}
do_something();
The variable x
is local to the function do_something
. It isn't a global variable because it's not available in every scope (i.e., outside of either of the functions, such as where do_something
is called).
However, would it be proper to say that "the variable x
is global to the function alert_x
? Can "global" be used as a relative term in this sense?