As far as I understand,
function sum(x,y){
return x+y;
}
and
var sum = function(x,y){
return x+y;
};
...are equivalent with the exception of function declaration hoisting in that:
alert(sum(20,30));
at the top of the script will run in the former case (function declaration) and cause an error in the latter (function expression). Would it be logical to make a conclusion that it's better to always use function declaration? Or am I missing something? To me it seems that it might be useful if you can use your functions first and then define what they should do.