JavaScript Quiz
Thirty questions covering the whole course. Choose an answer for each, then press Check answers at the bottom to see your score and an explanation for every question.
1. Where is the recommended place to load a script that works with the page?
defer downloads in parallel and runs after the HTML is parsed (lesson 02).
2. Which keyword should you use by default for variables?
Use const unless the value must be reassigned (lesson 05).
3. What does typeof null return?
A historic bug that can never be fixed (lesson 06).
4. What is "5" + 3?
If either side of + is a string, it concatenates (lesson 07).
5. What is "5" - 3?
- always converts to numbers (lesson 18).
6. Which comparison is true?
Loose equality treats null and undefined as equal; the others are all false (lessons 08 and 16).
7. What does 0 ?? 10 evaluate to?
?? only replaces null and undefined (lesson 08).
8. In a switch, what happens if you leave out break?
Fall-through continues until a break or return (lesson 10).
9. Which loop gives you the VALUES of an array?
for…in gives keys as strings (lesson 12).
10. What does "hello".at(-1) return?
Negative indexes count from the end (lesson 13).
11. Why does 0.1 + 0.2 === 0.3 return false?
Round for display, use integer cents for money (lesson 16).
12. Which of these values is truthy?
Every non-empty string is truthy, even "false" (lesson 19).
13. In new Date(2026, 0, 15), which month is it?
Months are zero-based in the Date constructor (lesson 20).
14. What does an arrow function NOT have of its own?
Arrows inherit this from the surrounding code (lesson 23).
15. What happens if you use a let variable before its declaration line?
let and const are hoisted but not initialised (lesson 25).
16. What is a closure?
Closures keep a live link to outer variables (lesson 26).
17. What does ["1", "2", "3"].map(parseInt) return?
map passes the index as parseInt's radix argument (lesson 28).
18. Which method changes the original array?
splice modifies in place; the others return new arrays (lesson 30).
19. What does find return when nothing matches?
findIndex returns -1; find returns undefined (lesson 31).
20. What does [10, 9, 1].sort() produce?
The default sort compares items as strings (lesson 32).
21. How do you make a copy of an array?
Assignment shares the same array; spread creates a new one (lesson 33).
22. What is the quickest way to remove duplicates from an array?
A Set only stores unique values (lesson 34).
23. What does Object.entries({ a: 1 }) return?
An array of [key, value] pairs (lesson 37).
24. Where do class methods actually live?
Classes are built on prototypes (lesson 38).
25. What makes a class field truly private?
#private fields can't be accessed outside the class (lesson 40).
26. What does JSON.stringify do with a function property?
Functions and undefined values are omitted (lesson 41).
27. Which property safely sets text that came from a user?
innerHTML would interpret markup and allow XSS (lesson 43).
28. What is event delegation?
It works because events bubble up (lesson 45).
29. Does fetch reject its promise for a 404 response?
fetch rejects only on network failure (lesson 49).
30. In what order does this print? setTimeout(() => log("A")); Promise.resolve().then(() => log("B")); log("C");
Synchronous code first, then microtasks (promises), then tasks (timers) (lesson 51).
Missed a few? Each explanation names the lesson to revisit. When you're ready, try the exercises.