What does `typeof null` return in JavaScript?
Answer & explanation
Answer: "object"
This is a longstanding JavaScript quirk: `null` is a primitive, but `typeof null` returns `"object"`.
Predict JavaScript output and test your understanding of scope, types, arrays, and async code.
A random set of up to 10 questions from JavaScript. Your answers stay on this page.
Open a topic above to explore the complete question bank.
Answer: "object"
This is a longstanding JavaScript quirk: `null` is a primitive, but `typeof null` returns `"object"`.
Answer: ===
`===` is strict equality. `==` may coerce types; `=` assigns a value.
let count = 6;
const next = () => ++count;
next();Answer: 7
The inner function closes over `count` and keeps access to the binding after `makeCounter` returns.
Answer: .catch()
`.catch(handler)` handles rejection. `.finally()` runs after either fulfillment or rejection and does not receive the result.
Answer: A new array containing each callback result
`map()` builds a new array from callback return values; it does not mutate the original array by itself.
___ count = 0;
count += 1;Answer: let
`let` declares a block-scoped variable that can be reassigned.