JavaScript Essentials Quiz sample questions with answers
10 questions from the JavaScript Essentials Quiz practice bank, spread across its domains. Pick your answer, then open the explanation to see why each option is right or wrong.
- Question 1Language Fundamentals
Which of these values are falsy in JavaScript? (Choose three.)
Choose 3.
- A
0 - B
""(an empty string) - C
null - D
"false" - E
[](an empty array) - F
{}(an empty object)
Show the answer and explanation
Answer: A and B and C
The falsy values are
false,0,-0,0n,"",null,undefinedandNaN. Everything else, including every object and array, is truthy.Why the other options are wrong
D. Any non-empty string is truthy, including the text "false".
E. All objects are truthy, including empty arrays.
F. All objects are truthy, however empty they are.
- A
- Question 2Functions and Scope
Variables declared with
letare hoisted, but reading them before the declaration line runs throws aReferenceError.- A
True
- B
False
Show the answer and explanation
Answer: A
letandconstbindings exist from the start of their block but are uninitialised (the temporal dead zone).varis hoisted and initialised toundefinedinstead.Why the other options are wrong
B. They are hoisted; the error comes from the temporal dead zone, not from a missing declaration.
- A
- Question 3Async JavaScript
When you
awaita promise that rejects inside atryblock, the matchingcatchblock receives the rejection reason.- A
True
- B
False
Show the answer and explanation
Answer: A
awaitunwraps fulfilled values and throws rejected ones, so ordinarytry/catch/finallyworks with async code.Why the other options are wrong
B. A rejected await behaves like a throw, so try/catch handles it.
- A
- Question 4The DOM and the Browser
Which statements about
IntersectionObserverare true? (Choose two.)Choose 2.
- A
It reports when an observed element enters or leaves the viewport or a chosen root element
- B
It is an efficient replacement for scroll listeners when lazy-loading images
- C
It runs its callback synchronously on every scroll event
- D
Each observer can watch only one element
- E
It needs a third-party library to work
Show the answer and explanation
Answer: A and B
Use
IntersectionObserverfor lazy loading, infinite scroll and "seen" tracking instead of measuring elements in scroll handlers.Why the other options are wrong
C. Callbacks are asynchronous and fire only when an intersection threshold is crossed.
D. One observer can observe any number of elements.
E. It is a built-in browser API.
- A
- Question 5Language Fundamentals
Object.freeze(obj)also freezes the objects nested insideobj.- A
True
- B
False
Show the answer and explanation
Answer: B
Object.freezeis shallow. For deep immutability, freeze recursively (or use an immutable data library).Why the other options are wrong
A. freeze is shallow: nested objects stay mutable unless you freeze them too.
- A
- Question 6Functions and Scope
Given
const user = { name: 'Ada', greet() { return this.name; } }, which calls rungreetwiththisset touser? (Choose two.)Choose 2.
- A
user.greet() - B
const g = user.greet; g() - C
user.greet.bind(user)() - D
setTimeout(user.greet, 0) - E
const { greet } = user; greet()
Show the answer and explanation
Answer: A and C
thisdepends on the call site. Method calls andbind,callorapplyset it; passing a method around as a value does not.Why the other options are wrong
B. The plain call loses the object, so this is undefined in strict mode.
D. The timer calls the detached function as a plain function.
E. Destructuring copies the function out of the object, so the call loses this.
- A
- Question 7Async JavaScript
You fetch three independent resources and want every result, including which ones failed, without stopping at the first error. Which should you use?
- A
Promise.all - B
Promise.allSettled - C
Promise.race - D
Promise.any
Show the answer and explanation
Answer: B
Promise.allSettledreturns{ status, value | reason }for every input, which suits independent requests where partial results are useful.Why the other options are wrong
A. Promise.all rejects as soon as any input rejects, so you lose the other results.
C. race settles with whichever promise settles first.
D. any resolves with the first success and ignores the rest.
- A
- Question 8The DOM and the Browser
Calling
event.stopPropagation()in a link's click handler also stops the browser from following the link.- A
True
- B
False
Show the answer and explanation
Answer: B
stopPropagation()halts bubbling and capturing;preventDefault()cancels the browser's default action. They are independent, and you can call both.Why the other options are wrong
A. stopPropagation only stops the event from reaching other elements' listeners.
- A
- Question 9Language Fundamentals
Which of these expressions evaluates to
true?- A
null == undefined - B
null == 0 - C
NaN == NaN - D
"" === 0
Show the answer and explanation
Answer: A
null == undefinedis true by a special rule of loose equality. It is whyvalue == nullis a common shorthand for checking "null or undefined"; prefer===everywhere else.Why the other options are wrong
B. null is only loosely equal to undefined; it is not converted to 0 by ==.
C. NaN is unequal to itself under both == and ===.
D. Strict equality never converts types, so a string and a number are never ===.
- A
- Question 10Functions and Scope
An arrow function gets its own
thisfrom the way it is called.- A
True
- B
False
Show the answer and explanation
Answer: B
Arrow functions capture
thislexically, which makes them ideal for callbacks inside methods and a poor choice for object methods themselves.Why the other options are wrong
A. Arrow functions have no this of their own, so call, apply and bind cannot change it.
- A
Practise all 40 JS-ESS questions
Start with the free 15-question diagnostic. It shows where to focus, and your results carry over if you sign up.