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.

  1. 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, undefined and NaN. 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.

  2. Question 2Functions and Scope

    Variables declared with let are hoisted, but reading them before the declaration line runs throws a ReferenceError.

    • A

      True

    • B

      False

    Show the answer and explanation

    Answer: A

    let and const bindings exist from the start of their block but are uninitialised (the temporal dead zone). var is hoisted and initialised to undefined instead.

    Why the other options are wrong

    • B. They are hoisted; the error comes from the temporal dead zone, not from a missing declaration.

  3. Question 3Async JavaScript

    When you await a promise that rejects inside a try block, the matching catch block receives the rejection reason.

    • A

      True

    • B

      False

    Show the answer and explanation

    Answer: A

    await unwraps fulfilled values and throws rejected ones, so ordinary try/catch/finally works with async code.

    Why the other options are wrong

    • B. A rejected await behaves like a throw, so try/catch handles it.

  4. Question 4The DOM and the Browser

    Which statements about IntersectionObserver are 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 IntersectionObserver for 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.

  5. Question 5Language Fundamentals

    Object.freeze(obj) also freezes the objects nested inside obj.

    • A

      True

    • B

      False

    Show the answer and explanation

    Answer: B

    Object.freeze is 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.

  6. Question 6Functions and Scope

    Given const user = { name: 'Ada', greet() { return this.name; } }, which calls run greet with this set to user? (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

    this depends on the call site. Method calls and bind, call or apply set 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.

  7. 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.allSettled returns { 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.

  8. 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.

  9. 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 == undefined is true by a special rule of loose equality. It is why value == null is 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 ===.

  10. Question 10Functions and Scope

    An arrow function gets its own this from the way it is called.

    • A

      True

    • B

      False

    Show the answer and explanation

    Answer: B

    Arrow functions capture this lexically, 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.

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.

Go to JS-ESS