function declaration and function expression?

  • Function Declaration → Hoisted, can be called before definition.
  • Function Expression → Not hoisted, assigned to a variable.

Example:

// Declaration
function greet() { return "Hello"; }

// Expression
let sayHi = function() { return "Hi"; };

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *