Checkpoint: Modern JavaScript
A checkpoint is a hands-on review that combines everything from the modern JavaScript track — template literals, optional chaining, array and object methods, symbols, getters/setters, Proxy, and BigInt — into one build challenge and a short quiz.
Learn Checkpoint: Modern JavaScript in our free JavaScript course — an interactive lesson with runnable examples, a practice exercise and a quick reference.
Part of the free JavaScript course at LearnCodingFast — hands-on lessons with examples you run in your browser, plus practice exercises and a quick quiz.
No new syntax here: this is where the pieces click together into something you could ship.
Here's the whole modern-JavaScript toolkit in one place. Each row links the idea to a one-line reminder.
Build a small utility that (1) reads each order's nested customer city safely with optional chaining, (2) groups orders by status using Object.groupBy , (3) finds the highest-value order with an array method, and (4) wraps a config object in a validating Proxy that rejects negative discounts. Fill in the blanks in the starter, then check against the full solution.
Notice how four separate lessons cooperate: ?. + ?? , Object.groupBy , the immutable toSorted , and a validating Proxy with Reflect.set .
Here is the completed solution as one runnable program, plus a template-literal report at the end. Run it to confirm every piece works together.
Answer each in your head, then reveal to check.
The nullish coalescing operator ?? . Unlike || , it only falls back for null and undefined , so a real 0 is preserved.
sort mutates the array in place; toSorted returns a new sorted array and leaves the original untouched.
Object.fromEntries(Object.entries(obj).map(...)) — convert to pairs, map them, then rebuild.
Symbol.for returns the same shared symbol from the global registry every time, while Symbol("x") always creates a new, unequal symbol.
Call Reflect.set(target, key, value) and return its result — that performs the default assignment and returns true .
JavaScript refuses to mix BigInt and Number. Convert first: 10n + BigInt(5) or Number(10n) + 5 .
Up next: Promise Combinators — coordinating many async operations. ⏩
Practice quiz
Which operator keeps a value of 0 but replaces undefined?
- || (logical OR)
- ?. (optional chaining)
- ?? (nullish coalescing)
- && (logical AND)
Answer: ?? (nullish coalescing). ?? only falls back for null and undefined, so a real 0 is preserved; || would replace it.
What is the difference between sort and toSorted?
- sort mutates in place; toSorted returns a new array
- They are identical
- toSorted mutates; sort returns a copy
- toSorted only works on numbers
Answer: sort mutates in place; toSorted returns a new array. sort reorders the original array; toSorted leaves it untouched and returns a sorted copy.
What does Object.fromEntries(Object.entries({a:1,b:2}).map(([k,v]) => [k, v*10])) produce?
- {a:1, b:2}
entries to pairs, map each value times 10, then fromEntries rebuilds: {a:10, b:20}.
Why use Symbol.for("x") instead of Symbol("x")?
- Symbol.for is faster
- Symbol.for returns the same shared symbol every time
- Symbol("x") is deprecated
- There is no difference
Answer: Symbol.for returns the same shared symbol every time. Symbol.for pulls from a global registry, so equal keys match; Symbol("x") always makes a new unequal symbol.
Inside a Proxy set trap, how do you perform the actual write?
- return Reflect.set(target, key, value)
Answer: return Reflect.set(target, key, value). Reflect.set forwards the default assignment and returns the boolean the trap must return.
What happens when you evaluate 10n + 5?
- 15n
- 15
- It throws a TypeError
- "105"
Answer: It throws a TypeError. JavaScript refuses to mix BigInt and Number; convert first, e.g. 10n + BigInt(5).
What does Object.groupBy(orders, o => o.status) return for statuses paid, open, paid?
- An array of statuses
- An object keyed by status with arrays of orders
- A Set of statuses
- A Map of counts
Answer: An object keyed by status with arrays of orders. Object.groupBy buckets items into an object whose keys are the returned group strings.
Which array method returns the FIRST element matching a condition?
- filter
- some
- map
- find
Answer: find. find returns the first matching element (or undefined); filter returns all matches as an array.
After Object.freeze({a:1}), what does assigning obj.a = 2 then reading obj.a give (non-strict)?
- 2
- 1
- undefined
- It throws
Answer: 1. freeze blocks the write; the value stays 1 (the assignment is silently ignored in non-strict mode).
What does [1, 2].flatMap(n => [n, n * 2]) produce?
flatMap maps each element to an array then flattens one level: [1, 2, 2, 4].