1. What does `typeof null` return?
- "null"
- "undefined"
- "object"
- "function"
Show answer
Answer: "object"
It's a long-standing JS bug kept for backward compatibility.
Lesson: Data Types
18 questions from the JavaScript Fundamentals: From Syntax to Async course, each with the correct answer and an explanation. Try to answer before you open the answer.
Answer: "object"
It's a long-standing JS bug kept for backward compatibility.
Lesson: Data Types
Answer: for...in
`for...in` is built specifically for enumerating an object's keys.
Lesson: Loops
Answer: filter
`filter` only keeps items that pass the test, so the result can never be longer than the input.
Answer: It compares items as strings by default
Pass (a, b) => a - b for numeric order.
Lesson: Searching & Sorting Arrays
Answer: 3
The empty slot skips index 1, so b picks up index 2, which holds 3.
Lesson: Destructuring Arrays & Objects
Answer: Because the closure keeps count alive between calls
The inner function closes over `count`, so it persists across separate calls to `counter()`.
Lesson: Closures
Answer: Stops the browser's default action for that event
For example, it stops a form's default submit-and-reload behavior — bubbling is a separate concern handled by stopPropagation().
Lesson: Event Listeners & Bubbling
Answer: Any rejection from earlier in the chain
A rejection at any earlier .then() skips the remaining .then() calls and jumps straight to the nearest .catch().
Lesson: Promises
Answer: Because it queues fn to run after the current call stack finishes
Its callback still waits for the call stack to clear, even with a 0ms delay.
Lesson: JSON, Regex & the Event Loop
Answer: "object"
A long-standing quirk: null reports as object.
Lesson: JSON, Regex & the Event Loop
Answer: const
const is block-scoped and fixes the binding.
Lesson: JSON, Regex & the Event Loop
Answer: [2, 4, 6]
map returns a new array.
Lesson: JSON, Regex & the Event Loop
Answer: ??
|| also falls back on 0 and empty strings.
Lesson: JSON, Regex & the Event Loop
Answer: A function that remembers variables from where it was created
Closures keep access to their creation scope.
Lesson: JSON, Regex & the Event Loop
Answer: Stops the browser's default action
For example it stops a form from submitting.
Lesson: JSON, Regex & the Event Loop
Answer: Pauses that function until the promise settles
Other code keeps running while it waits.
Lesson: JSON, Regex & the Event Loop
Answer: fn is queued until the call stack is clear
The event loop runs queued callbacks after the current code.
Lesson: JSON, Regex & the Event Loop
Answer: undefined
Optional chaining short-circuits to undefined.