← Lesson
BitWithBite
Full-Stack · Quick Reference

Lesson 15 — Functions Cheat Sheet

Full-Stack
In one line: Declarations are hoisted, expressions aren't, and arrow functions have no own "this" — which is exactly why React uses them for handlers.

Key Ideas

1Declaration. function name(){} — hoisted.
2Expression. const name = function(){} — not hoisted.
3Arrow. const name = () => {} — no own this.
4Default params. function f(x = 10) {}.
5Destructuring. Pull values from objects/arrays directly.

Examples

const greet = name => `Hello, ${name}!`; const power = (base, exp = 2) => base ** exp; power(3); // 9 const { name, age } = user; const [first, ...rest] = [1,2,3,4];