Scope Demo



var global = "I'm a global variable";

function main(){
  var builtInMain = "I was built in the main function";

  alert("global is : " + global);
  alert("Inside main, builtInMain is: \n" + builtInMain);

  second();

} // end main

function second(){
  alert("the next line will probably contain an error...");
  alert("in the second function, builtInMain is: \n" + builtInMain);
} // end second


Andy Harris