JavaScript - The var keyword is only applied to one variable

javascript

// JavaScript - The var keyword is only applied to one variable:

(function(){
  var a = b = 3;
})();

In the above code, only a is local to that function, and b is a global variable, 
and therefore:

console.log("a defined? " + (typeof a !== 'undefined')); //logs "a defined? false"
console.log("b defined? " + (typeof b !== 'undefined')); //logs "b defined? true"
Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License