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.
- 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
sortmethod expects the comparison function to return a negative number, zero, or a positive number.a.price - b.pricecorrectly returns a negative value ifais smaller thanb, sorting them in ascending order. - 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.parseshould 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. - Question 3IntermediateSelect 2
Variables, Types, and Collections · Type Coercion
Which of the following expressions evaluates to
truein JavaScript? (Select TWO)Show answer & explanation
Correct answers: C, D
null == undefinedis true because they are loosely equal.[](empty array) is a truthy value, so!![]is true.Objects (including arrays) are always truthy in JavaScript.
- 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
greetingargument?Show answer & explanation
Correct answer: C
The syntax
greeting = 'Hello'defines a default parameter. If the caller does not provide a value forgreeting(or passesundefined), the function uses 'Hello'. - 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.040000000000001instead of8.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.
- 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
WeakMapallows 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 theWeakMapis automatically removed. - 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. - Question 8Intermediate
Variables, Types, and Collections · Strings, Numbers, and Dates
Which statement correctly checks if a value
xis strictly equal toNaN?Show answer & explanation
Correct answer: C
In JavaScript,
NaNis the only value that is not equal to itself, sox === NaNreturns false.Number.isNaN(x)is the correct and robust way to check if a value is strictlyNaN.
Ready for the real thing?
The full JS-Dev-101 simulator has every exam-style question, timed mode, and instant scoring.