JS Built-ins
Variablesintermediate

Variables β€” function declaration hoisting

Function declarations are fully hoisted

Unlike var (which hoists with undefined), a function declaration is fully hoisted β€” you can call it before the line where it appears in the source.

Challenge: Write functionHoisting() that:

  1. Calls greet() before its declaration
  2. Declares function greet() { return 'hoisted!' } after the call
  3. Returns the result of the early call
πŸ’‘ Hints (1)
  • β€’ Function declarations (not expressions) are fully hoisted with their body