JavaScript Core ⚡ Recently updatedUpdated on Jun 30, 2026 — this content may still be evolving.
JavaScript Core: Revision Sheet
One-page rapid review. Read this the night before your interview.
Types & Coercion
| Expression | Result |
|---|---|
typeof null | "object" |
typeof NaN | "number" |
[] + [] | "" |
0.1 + 0.2 === 0.3 | false |
| Falsy values | 0, "", null, undefined, NaN, false |
var vs let vs const
var: function-scoped, hoisted asundefinedlet/const: block-scoped, TDZ until declarationconst: binding constant, object contents can still mutate
Event Loop Order
- Synchronous code (call stack)
- Microtasks (Promises,
queueMicrotask) - Macrotasks (
setTimeout,setInterval, I/O)
Closures
Inner function + access to outer variables after outer returns. Use: data privacy, factories, debounce/throttle.
this Binding (priority)
new→ new objectcall/apply/bind→ explicit- Method call → object
- Standalone →
undefined(strict) / global (sloppy) - Arrow → lexical (outer scope)
Array Methods
| Method | Mutates? | Returns |
|---|---|---|
map | No | New array |
filter | No | New array |
reduce | No | Single value |
push/pop/splice | Yes | Varies |
slice | No | Shallow copy |
sort | Yes | Same array |
Object Copy
const shallow = { ...obj };
const deep = structuredClone(obj);
Promises
Promise.all([p1, p2]) // all resolve or first reject
Promise.race([p1, p2]) // first settle
Promise.allSettled([...]) // wait for all, never reject
async/await
async function getData() {
try {
const res = await fetch(url);
if (!res.ok) throw new Error(res.status);
return await res.json();
} catch (e) {
// handle
}
}
Debounce vs Throttle
- Debounce: wait until activity stops (search input)
- Throttle: max once per interval (scroll)
Prototype Chain
obj.__proto__ === Constructor.prototype
instanceof checks prototype chain
ES6 Destructuring
const { name, age = 18 } = user;
const [first, ...rest] = arr;
Optional Chaining & Nullish
user?.address?.city
value ?? 'default' // only null/undefined, not 0 or ''
Quick Polyfill Reminders
- bind: return function that calls original with fixed
this+ args - debounce:
clearTimeout+setTimeout - Promise.all: array in order, fail fast
Interview Phrases That Impress
- “I’d use
===to avoid type coercion” - “That’s a microtask, so it runs before setTimeout”
- “Arrow function inherits
thislexically” - “I’d shallow copy with spread, deep copy with structuredClone”
- “Debounce for search, throttle for scroll”
Red Flags to Avoid
- “Closures are just nested functions”
- Using
varin new code - Ignoring promise error handling
- Arrow functions as object methods when
thisis needed