Javascript – “Usual” functions vs function variables in JavaScript

javascript

Is there any difference between

function MyFunc() {
    // code...
}

and

var MyFunc = function() {
    // code...
};

in JavaScript?

Best Answer

I know that a difference between them is that named functions work everywhere regardless you declare them, functions in variables don't.

a();//works   
function a(){..}

works

a();//error
var a=function(){..}

doesn't work but if you call it after the declaration it works

var a=function(){..}
a();//works