Local Scope



examples/javascript/local_scope_var.js
name = 'Foo'
console.log(name);    // Foo

function f() {
   console.log(name); // undefined
   var name = 'Bar'
   console.log(name); // Bar
}
f();

console.log(name);    // Foo

examples/javascript/local_scope_var_var.js
var name = 'Foo'
console.log(name);    // Foo

function f() {
   console.log(name); // undefined
   var name = 'Bar'
   console.log(name); // Bar
}
f();

console.log(name);    // Foo