What is the difference between `function declarations` and `function expressions` regarding hoisting?

JavaScript Professional Medium

JavaScript Professional — Medium

What is the difference between `function declarations` and `function expressions` regarding hoisting?

Key points

  • Function declarations are hoisted entirely
  • Function expressions assigned to variables are hoisted differently
  • Declarations can be called before their line
  • Expressions are hoisted as undefined or in TDZ
  • Understanding hoisting is crucial for JavaScript functions

Ready to go further?

Related questions