There are two Stage of javascript execution,
1) Creation Stage
2) Execution Stage
Creation Stage : In creation stage all the variable and function are created with a value undefined in case of variable
for eg in your second case
abc();
function abc(x,y){
return x + y;
}
Here function abc() is defined in its creation stage,so even though you called it first it will not give you any error.
Because abc() it is called during its execution stage
As you are not passing any variable to function x and y will be undefined in this case
Execution Stage : In execution stage function abc is called which was defined during its creation stage.So no matter wherever you call a function you will never get an error.
Javascript is synchronous
One very important thing in javascript is LEXICAL ENVIRONMENT
ie where your function or variable sits.in which lexical environement.