JavaScript - The var keyword is only applied to one variable
// 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"
page revision: 0, last edited: 14 Nov 2016 07:40