What is the difference between function expression and function definition in relation to Hoisting in Javascript?

Asked

Viewed 203 times

2

What is the difference between function expression (named or unspecified) and function definition in relation to Hoisting no Javascript?

Named function expression syntax:

var somar = function somar(a, b) {
   return a + b;
};

Function expression syntax, better known as anonymous function:

var somar = function(a, b) {
   return a + b;
};

Syntax definition of function:

function somar(a, b) {
   return a + b;
}

And where it is most recommended to use each of them?

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.