JS-Dev-101 Sample Questions

JS-Dev-101 Sample Questions & Answers

Object, function and class implementation carries the largest share, alongside variable types and collections, browser events and DOM manipulation, debugging and error handling, asynchronous programming and the event loop, Node.js basics, and unit testing.

Launch the full JS-Dev-101 simulator →

Showing 8 of 17 free samples.

  1. Question 1Intermediate

    Variables, Types, and Collections · Array Data Manipulation

    A developer needs to sort an array of product objects by price (ascending). The price is a numeric property.

    const products = [{id: 1, price: 100}, {id: 2, price: 5}, {id: 3, price: 25}];

    Which sort implementation works correctly?

    Show answer & explanation

    Correct answer: D

    The sort method expects the comparison function to return a negative number, zero, or a positive number. a.price - b.price correctly returns a negative value if a is smaller than b, sorting them in ascending order.

  2. Question 2Advanced

    Variables, Types, and Collections · JSON Operations

    A developer is parsing a JSON string received from an API. The string contains a date field in ISO format. The developer wants to automatically convert this string into a JavaScript Date object during parsing.

    Which feature of JSON.parse should be used?

    Show answer & explanation

    Correct answer: B

    JSON.parse() accepts a second argument called the 'reviver' function. This function is called for each key-value pair and can be used to transform values (like converting an ISO date string into a Date object) before the final object is returned.

  3. Question 3IntermediateSelect 2

    Variables, Types, and Collections · Type Coercion

    Which of the following expressions evaluates to true in JavaScript? (Select TWO)

    Show answer & explanation

    Correct answers: C, D

    null == undefined is true because they are loosely equal. [] (empty array) is a truthy value, so !![] is true.

    Objects (including arrays) are always truthy in JavaScript.

  4. Question 4Beginner

    Variables, Types, and Collections · Variables and Initialization

    A developer writes the following function to create a greeting:

    function greet(name, greeting = 'Hello') {
    return `${greeting}, ${name}!`;
    }
    

    What feature is being used for the greeting argument?

    Show answer & explanation

    Correct answer: C

    The syntax greeting = 'Hello' defines a default parameter. If the caller does not provide a value for greeting (or passes undefined), the function uses 'Hello'.

  5. Question 5Intermediate

    Variables, Types, and Collections · Strings, Numbers, and Dates

    A financial application calculates tax using the following code:

    let price = 100.50;
    let taxRate = 0.08;
    let total = price * taxRate;
    console.log(total);
    

    The output is 8.040000000000001 instead of 8.04. What is the primary cause of this behavior?

    Show answer & explanation

    Correct answer: C

    JavaScript uses the IEEE 754 standard for floating-point arithmetic. This binary representation cannot precisely represent certain decimal fractions, leading to small precision errors in calculations.

  6. Question 6Advanced

    Variables, Types, and Collections · Array Data Manipulation

    You are implementing a cache mechanism where keys must be objects (e.g., DOM elements) and you do not want to prevent garbage collection of these keys if they are removed from the DOM.

    Which data structure is most appropriate?

    Show answer & explanation

    Correct answer: A

    WeakMap allows objects to be used as keys without creating a strong reference to them. If the object key is garbage collected (e.g., removed from the DOM and no longer referenced elsewhere), the entry in the WeakMap is automatically removed.

  7. Question 7Intermediate

    Variables, Types, and Collections · Variables and Initialization

    A developer needs to copy properties from multiple source objects into a single target object. If properties overlap, the properties from the later source objects should overwrite earlier ones.

    Which method accomplishes this?

    Show answer & explanation

    Correct answer: C

    Object.assign(target, source1, source2) copies enumerable own properties from one or more source objects to a target object. Properties in later sources overwrite those in earlier sources or the target.

  8. Question 8Intermediate

    Variables, Types, and Collections · Strings, Numbers, and Dates

    Which statement correctly checks if a value x is strictly equal to NaN?

    Show answer & explanation

    Correct answer: C

    In JavaScript, NaN is the only value that is not equal to itself, so x === NaN returns false. Number.isNaN(x) is the correct and robust way to check if a value is strictly NaN.

Ready for the real thing?

The full JS-Dev-101 simulator has every exam-style question, timed mode, and instant scoring.