Quick answer: For placement revision, learn these JavaScript fundamentals: seven primitive types, === over ==, let and const scope, closures, the main array methods, references and copies, how this is set, promise states, event loop order and basic DOM events. This cheat sheet puts them in short tables with real outputs, so you can cover one column and test yourself.
This JavaScript fundamentals cheat sheet is for the days before a placement test or interview. Cover the right column of a table, say the answer, then check. Anything you miss goes on your study list.
These JavaScript fundamentals notes assume you have met the topics before. If not, start with the beginner tutorial. Outputs below come from Node.js.
Types and equality
| Topic | Remember |
|---|---|
| Primitives | string, number, bigint, boolean, undefined, null, symbol |
| Everything else | object (arrays and functions too) |
| Falsy | false, 0, -0, 0n, "", null, undefined, NaN |
| Truthy surprises | [], {}, "0", "false" |
=== |
Same type and same value |
== |
May convert types first |
?? |
Right side only for null or undefined |
|| |
Right side for any falsy value |
?. |
Stops safely at null or undefined |
console.log(typeof null); // object
console.log(typeof function () {}); // function
console.log(Array.isArray([])); // true
console.log("5" + 2); // 52
console.log("5" - 2); // 3
console.log(null == undefined); // true
console.log(Number("")); // 0
console.log(Number("12px")); // NaN
console.log(parseInt("12px", 10)); // 12
Scope, hoisting and functions
| var | let | const | |
|---|---|---|---|
| Scope | Function | Block | Block |
| Reassign | Yes | Yes | No |
| Declare again in same scope | Yes | No | No |
| Read before declaration | undefined |
ReferenceError | ReferenceError |
| Function form | Hoisted with body | Own this |
Works with new |
|---|---|---|---|
| Declaration | Yes | Yes | Yes |
| Expression | No | Yes | Yes |
| Arrow | No | No | No |
Closure in one line: a function that remembers variables from where it was created.
const multiplier = (by) => (n) => n * by;
const triple = multiplier(3);
console.log(triple(5)); // 15
Common mistake: Saying "
constmeans the value never changes". It means the variable cannot be reassigned. You can still push to aconstarray.
Array and string methods
| Method | Returns | Changes original? |
|---|---|---|
map(fn) |
New array, same length | No |
filter(fn) |
New array of matches | No |
find(fn) |
First match or undefined |
No |
reduce(fn, start) |
One result | No |
some / every |
Boolean | No |
includes(x) |
Boolean | No |
slice(a, b) |
Copied part, b not included |
No |
splice(i, n) |
Removed items | Yes |
push / unshift |
New length | Yes |
pop / shift |
Removed item | Yes |
sort / reverse |
Same array | Yes |
toSorted / toReversed |
New array | No |
const a = [10, 2, 33];
console.log(a.toSorted()); // [ 10, 2, 33 ]
console.log(a.toSorted((x, y) => x - y)); // [ 2, 10, 33 ]
console.log(a.reduce((s, n) => s + n, 0)); // 45
console.log(a.at(-1)); // 33
console.log("a,b".split(",")); // [ 'a', 'b' ]
console.log(" hi ".trim().toUpperCase()); // HI
Strings cannot be changed in place. Every string method returns a new value.
Objects, copies and this
| Task | Code |
|---|---|
| Keys, values, pairs | Object.keys(o), Object.values(o), Object.entries(o) |
| Own property check | Object.hasOwn(o, "id") |
| Take values out | const { id, name = "Guest" } = o |
| Shallow copy | { ...o } |
| Deep copy of plain data | structuredClone(o) |
| To and from text | JSON.stringify(o), JSON.parse(text) |
| How it is called | this is |
|---|---|
obj.fn() |
obj |
fn() in strict mode |
undefined |
new Fn() |
The new object |
fn.call(x) / fn.apply(x) |
x |
| Arrow function | Taken from the code around it |
| DOM listener, normal function | The element with the listener |
const one = { tags: ["js"] };
const two = { ...one };
two.tags.push("css");
console.log(one.tags); // [ 'js', 'css' ]
console.log(one === { ...one }); // false
Spread copied the outer object, but tags is still the same array in both.
Async, DOM and events
| Term | One line |
|---|---|
| Promise states | pending, then fulfilled or rejected |
async function |
Always returns a promise |
await |
Pauses this function until a promise settles |
Promise.all |
Rejects on the first rejection |
Promise.allSettled |
Waits and reports every result |
fetch on a 404 |
Does not reject; check response.ok |
| Event loop order | Sync code, then microtasks, then timers |
setTimeout(() => console.log("timer"), 0);
Promise.resolve().then(() => console.log("promise"));
console.log("sync");
sync
promise
timer
| DOM task | Code |
|---|---|
| Find one / all | querySelector(css) / querySelectorAll(css) |
| Set safe text | el.textContent = value |
| Toggle a class | el.classList.toggle("open") |
| Listen | el.addEventListener("click", fn) |
| Stop default action | event.preventDefault() |
| Stop bubbling | event.stopPropagation() |
| Delegation | Parent listener plus event.target.closest(css) |
| Save text | localStorage.setItem(key, value) |
Interview note: Interviewers often combine the two topics: "A
fetchgot a 500 reply. Didcatchrun?" Not by itself. Checkresponse.okand throw your own error.
JavaScript fundamentals quick revision: output traps
Use this table for JavaScript fundamentals quick revision. Cover the middle column and predict each result.
| Code | Result | Why |
|---|---|---|
0.1 + 0.2 === 0.3 |
false |
Binary decimals |
[] + [] |
"" |
Both become empty strings |
[1] === [1] |
false |
Different references |
NaN === NaN |
false |
Use Number.isNaN |
"b" + "a" + +"a" |
"baNaN" |
Unary + gives NaN |
[1, 2, 3].indexOf(4) |
-1 |
Not found |
3 > 2 > 1 |
false |
true > 1 is 1 > 1 |
Math.max() |
-Infinity |
No arguments |
How to use this JavaScript fundamentals cheat sheet
There is no JavaScript fundamentals PDF to download. To keep a copy, print this page and choose "Save as PDF".
- First pass: cover each table and mark what you miss.
- Second pass: type the code blocks from memory and run them.
- Third pass: solve five practice problems without help.
- Last pass: answer ten random JavaScript fundamentals interview questions aloud. For newer syntax, add the ES6 question set.
Pro tip: Keep a "got it wrong" list of ten lines at most. On the test morning, read only that list.
For a full plan after JavaScript, read the full stack developer course guide. At CodeBegun, the Full Stack Web Development programme includes 5+ interview opportunities through a 60+ company network, subject to the placement policy and eligibility. These are chances to interview, and the hiring decision stays with the employer.
Frequently asked questions
Is there a PDF of this JavaScript cheat sheet?
There is no separate PDF to download. Open this page in your browser, choose Print and then Save as PDF to keep your own copy. You can also bookmark it on your phone for revision before a test.
Which JavaScript topics should I revise first for placements?
Start with equality, scope and hoisting, closures, array methods, this, promises and the event loop. These appear often in output questions. Finish with DOM events if the role involves frontend work.
Can I learn JavaScript from a cheat sheet alone?
No. A cheat sheet helps you remember what you already understand. Learn each topic with code first, solve small problems, and then use this page to check your memory.
How long does it take to revise JavaScript fundamentals?
If you have already learned the topics, two focused sessions of about two hours are usually enough for a first pass. Spend the first on tables and the second on writing code and predicting output.
Should I memorise every array method?
No. Know map, filter, find, reduce, some, every, includes, slice, splice and sort very well. For each one, remember what it returns and whether it changes the original array.
Want help turning revision into clear interview answers? Book a free demo class for our Full Stack Web Development programme.
