Back to library
๐ŸŸจ

JavaScript essentials

Core JS concepts every web developer should know cold.

12 cardsยท PublicยทShared deck โ€” read only
Cards in this deck
01
What is the difference between `let` and `var`?
`let` is block-scoped and not hoisted to the top of its scope (it lives in the temporal dead zone). `var` is function-scoped and hoisted, initialised to `undefined`.
02
What does `===` do that `==` doesn't?
`===` compares both type and value with no coercion. `==` performs type coercion before comparing, so `0 == '0'` is true while `0 === '0'` is false.
03
What is a closure?
A closure is a function that retains access to the variables from the scope in which it was created, even after that scope has finished executing.
04
What does `Array.prototype.map` return?
A new array of the same length, where each element is the result of calling the callback on the corresponding element of the original. It does not mutate the original.
05
What is the event loop?
The event loop is the runtime mechanism that pulls tasks off the macrotask and microtask queues and runs them on the call stack, allowing JS to handle async operations on a single thread.
06
What is `Promise.all` vs `Promise.allSettled`?
`Promise.all` resolves with all results or rejects on the first failure. `Promise.allSettled` always resolves, with an array of `{status, value|reason}` for each promise.
07
What does the spread operator (`...`) do on an array?
It expands the iterable's items in place. `[...a, ...b]` creates a new array with all elements of `a` followed by all elements of `b`.
08
What is destructuring?
Syntax that unpacks values from arrays or properties from objects into distinct variables, e.g. `const { name, age } = user`.
09
What is hoisting?
JS's behaviour of moving declarations to the top of their containing scope before execution. `var` and function declarations are hoisted; `let`/`const` declarations are hoisted but not initialised.
10
What does `this` refer to inside an arrow function?
Arrow functions don't have their own `this` โ€” they inherit it from the lexical scope where they were defined.
11
What is event delegation?
A technique where you attach a single event listener to a common ancestor element instead of each child, then handle events as they bubble up. Reduces listener count and works with dynamically added elements.
12
What is the difference between `null` and `undefined`?
`undefined` means a variable has been declared but not assigned. `null` is an explicit assignment representing 'no value'. `typeof null === 'object'` (a longstanding bug).