In JavaScript, we have three ways to write any functions: function declaration, function expression, and arrow functions.

But I focused on the function expression and function declaration concept in this article.

Before talking about the key differences between them let see how they look.

Function Declaration

function foo(){
alert('hello')
}
foo();

The way is to write a function declaration is shown above. What we see?

  1. Function Declarations begins with the keyword “function”.
  2. You don’t need any variable assignment for it.

Function expression

let name = function foo(){
alert('hello')
};
foo();

#javascript #coding #javascript-tips

JavaScript Fundamentals. Function expression vs. Function declaration
3.00 GEEK