What is the difference between below snippets?
var a = 0;
function b(){
a = 10;
return function a(){};
}
b();
console.log(a); // => 10
and
var a = 0;
function b(){
a = 10;
return
function a(){};
}
b();
console.log(a); // => 0
It has something to do with JavaScript hoisting, but my understanding of the concept gives exactly the opposite output.