I was playing around Java script. I was expecting an output of 10 twice. Since I have declared var a = b = 10; here I struck, got error saying "a" is undefined and hiding that console.log(a); next console.log(b) gives me output as 10. I am not getting how "a" become undefined, even the console is after the function execution it must be undefined to b as well. or Is this wrong way to assign a value. Any clarification is on scenario is much appreciated.
(function(){
var a = b = 10;
})();
console.log(a);
console.log(b);
(function(){
var a = b = 10;
})();
//console.log(a);
console.log(b);