JavaScript Skills Audio Quiz — Questions & Answers

This quiz contains 10 questions. Below is a complete reference of all questions, answer choices, and correct answers. You can use this section to review after taking the interactive quiz above.

  1. Question 1: Promise Polyfill Functionality

    In JavaScript, what is the primary purpose of a Promise polyfill?

    • To provide Promise functionality in environments where Promises are not natively supported
    • To automatically retry asynchronous code on failure
    • To handle CSS animations efficiently
    • To polyfill only arrow functions
    • To add types to all promise-based functions
    Show correct answer

    Correct answer: To provide Promise functionality in environments where Promises are not natively supported

  2. Question 2: Arrow Function Syntax

    Which one of the following is the correct way to write an arrow function that returns the sum of two numbers 'a' and 'b'?

    • (a, b) => a + b
    • function(a, b) => { return a + b; }
    • [a, b] => { return a + b }
    • a, b -> a + b
    • (a; b) => { return a + b }
    Show correct answer

    Correct answer: (a, b) => a + b

  3. Question 3: Identifying Closures

    What is a closure in JavaScript?

    • A function having access to its own scope, the outer function's scope, and the global scope
    • A way to close the browser tab automatically
    • A block of code that runs immediately after it is defined
    • An error handling mechanism
    • A pre-compiled JavaScript file
    Show correct answer

    Correct answer: A function having access to its own scope, the outer function's scope, and the global scope

  4. Question 4: Async and Await

    What does the 'await' keyword do inside an 'async' function in JavaScript?

    • It pauses the execution until the promise is resolved
    • It runs the code synchronously
    • It throws an error if the promise is rejected
    • It creates a new thread
    • It defines a global variable
    Show correct answer

    Correct answer: It pauses the execution until the promise is resolved

  5. Question 5: LRUCache Implementation

    Which feature does a typical Least Recently Used (LRU) cache provide?

    • Removes the least recently accessed entry when the maximum size is reached
    • Always keeps the oldest entry regardless of access
    • Caches only successful network requests
    • Uses only weak references to stored objects
    • Ignores duplicate cache keys
    Show correct answer

    Correct answer: Removes the least recently accessed entry when the maximum size is reached

  6. Question 6: Higher-Order Functions

    What is a higher-order function in JavaScript?

    • A function that takes another function as an argument or returns a function
    • A function that always executes asynchronously
    • A function that is hoisted to the top of its scope
    • A function with infinite recursion
    • A function only usable inside classes
    Show correct answer

    Correct answer: A function that takes another function as an argument or returns a function

  7. Question 7: Object.entries() Usage

    What does Object.entries(obj) return in JavaScript?

    • An array of key-value pairs from the object
    • A list of all values of the object
    • A function reference to the object constructor
    • A sorted array of object keys
    • An iterable of prototype methods
    Show correct answer

    Correct answer: An array of key-value pairs from the object

  8. Question 8: Identifying Asynchronous Patterns

    Which of the following is NOT a recognized asynchronous programming pattern in JavaScript?

    • Thread locks
    • Promises
    • Callbacks
    • Async functions
    • Event listeners
    Show correct answer

    Correct answer: Thread locks

  9. Question 9: Code Output: String Manipulation

    Given the code snippet: const result = 'hello'.split('').reverse().join(''); What is the value of 'result'?

    • olleh
    • hello
    • hellohello
    • ehllo
    • heoll
    Show correct answer

    Correct answer: olleh

  10. Question 10: Dictionary Lookups in JavaScript

    In JavaScript, which approach checks if a string 'word' exists as a key in a given dictionary object called 'dict'?

    • 'word' in dict
    • dict.hasString(word)
    • word == dict.key
    • dict[word] = true;
    • dict.includes(word)
    Show correct answer

    Correct answer: 'word' in dict