JavaScript interviews probe mental models: scope and closures, this binding, hoisting, the event loop, and promises. Framework trivia is secondary. Be ready to write a small debounce, explain ===, and say what let does differently from var.
This JavaScript cheat sheet is written for people searching for a fast, accurate reference: students, junior developers, and teams shipping production software. Pin it, copy the snippets, and come back when syntax slips.
Quick reference
- Closure: A function remembers variables from the scope where it was created, even after that scope returned.
- this: Depends on call site: method,
call/apply,new, or lexical in arrows. - Hoisting:
varand function declarations hoist.let/constare in the TDZ until initialized. - Event loop: Call stack runs to empty; then microtasks (promises); then macrotasks (timeouts, I/O).
- ===: No coercion.
==coerces and is a bug factory. - Prototype: Objects delegate via
[[Prototype]]. Classes are syntax over this. - Truthy:
0,"",null,undefined,NaN,falseare falsy.[]and{}are truthy. - Debounce: Delay a function until calls stop. Throttle limits rate. Know the difference.
Copy-paste examples
Closure counter and lexical this
The inner function closes over n. The arrow inside the method keeps this from the method.
function makeCounter(start = 0) {
let n = start;
return () => ++n;
}
const c = makeCounter();
console.log(c(), c()); // 1 2
const api = {
token: 'abc',
headers: function () {
return () => ({ Authorization: this.token });
},
};Common mistakes
- Confusing
thisin arrows vs methods and “fixing” it with random.bind(this). - Saying JavaScript is multi-threaded because of async.
- Mutating arguments or prototypes in interview code without discussing the cost.
- Cannot explain a promise vs a callback besides “async/await is newer.”
FAQ
- What is hoisting in one example?
console.log(a)beforevar a = 1printsundefined. The same withletthrows. Function declarations are available before their line.
- How do you clone an array of objects? Shallow:
[...list]orlist.map. Deep:structuredClone. Mention that nested objects stay shared on shallow copy.
- null vs undefined?
undefinedmeans not assigned.nullis an intentional empty object value.typeof nullis"object"— a historic bug.
Related JavaScript cheat sheets
- Javascript Cheat Sheet 2026
- Javascript Array Methods Cheat Sheet
- Javascript String Methods Cheat Sheet
Build with this stack
When a cheat sheet is not enough — you need a production app, a student FYP, or a custom dashboard — ArpaNeuro builds custom web development and also sells ready-made source code. Request a quote and tell us the stack.
Browse software development services or the source code marketplace if you want a working codebase instead of starting from a blank file.