Compare a function declaration, a function expression and an arrow function. How do they differ in hoisting, this, and arguments?
Show the explanation
Model answer.
function add(a, b) { return a + b; } // declaration
const sub = function (a, b) { return a - b; }; // expression
const mul = (a, b) => a * b; // arrow function- Hoisting: a declaration is hoisted with its body, so you can call it above where it is written. Expressions and arrows are only available after the line runs (the variable is hoisted, the function is not).
- `this`: declarations and expressions get their own
this, decided by how they are called. Arrow functions have no own `this`; they use thethisof the surrounding code. That makes arrows ideal for callbacks inside methods, and wrong as object methods that needthis. - `arguments`: regular functions have an
argumentsobject; arrows do not (use rest parameters...args). - `new`: regular functions can be constructors; arrows cannot.
Rule of thumb: arrows for short callbacks, declarations for named top-level functions, and class methods for object behaviour.
Original UniCircle question. Last reviewed 22 Oct 2026.
