You are misleading the code in a style that makes people think that execution order matters. The standard JavaScript engine these days will accept this and reformat it before launching it:
var a = 1,
b = function() {
var a = function() {};
a = 10;
return;
};
b();
alert(a);
Now you can understand what is really happening. "a" is again declared inside the function "b", so there are actually two "a" variables. One of them is "window.a" and the other is "b var a", but NOT "ba" because it is not available outside of a closure or function.
In other words, you get what you encode.
, .