Exam Information
Free practice questions with explanations
Salesforce JS-Dev-101 Practice Questions
Answer a question to see the correct answer and the explanation, or click Show answer. Newest questions first.
- Questions
- 12
- Answered
- 0
- Correct
- 0
- Score
- -
-
1 Question 1 Single choice Objects, Functions, and Classes
A healthcare billing team maintains a JavaScript class PatientAccount with a method applyCopay(amount) that reads this.balance. A developer needs to pass the method to a reporting utility that invokes it as a standalone function, and the copay calculation must still update the correct account balance without creating a new object per call. The team also requires that the change remain compatible with an older bundle that loads the class as a plain constructor function, and that no additional runtime dependencies be introduced. Which change meets these requirements?
Correct Answer: DExplanationBinding in the constructor fixes this for the instance while keeping the class as a plain constructor function, so it works in the older bundle without adding dependencies, and the bound reference is created once per instance rather than on every call. Arrow-function class fields depend on class field syntax, which the older bundle does not support. Wrapping the call in a closure works but leaves the method itself unbound and pushes the burden onto every caller, against the reporting utility's design. Declaring the method static removes access to this.balance entirely, so it cannot update an instance's balance.
-
2 Question 2 Single choice Asynchronous Programming
A logistics control service must fetch carrier rates from three external APIs for the same shipment and display the result within a two-second SLA. Each API sometimes takes longer than two seconds, and the business wants the page to show whichever rates have arrived by the deadline rather than waiting for the slowest provider. Failures from one provider must not hide the successful responses from the others. The implementation runs in a modern browser with no polyfills. Which approach best satisfies these requirements?
Correct Answer: BExplanationPromise.allSettled waits for every provider to either resolve or reject, so one failing carrier cannot discard the others, and racing each request against a timer enforces the two-second cutoff so slow providers are dropped rather than blocking the page. Promise.all rejects as soon as any member rejects, which hides the successful rates. Sequential awaits serialize the requests and push total latency past the SLA. Promise.race returns the first settlement, which may be a fast failure, and it discards the other two providers' results.
-
3 Question 3 Single choice Variables, Types, and Collections
A subscription billing service stores invoice amounts in a JavaScript object and must compute a month-end total in a reporting job. Amounts arrive from an upstream system as strings with two decimals, such as "19.99" and "5.00". The finance team has found that the running total sometimes shows a rounding error such as 24.989999999999998. The job must keep the existing data format, avoid rewriting upstream parsers, and produce a total that is correct to the cent when displayed. A reviewer also points out that a line item with a missing amount currently becomes NaN in the total. Which change best meets these requirements?
Correct Answer: DExplanationWorking in integer cents avoids binary floating-point error in the accumulation, and Math.round guards against values like 19.99 * 100 being stored as 1998.9999999999998. Skipping non-finite values prevents a missing amount from turning the total into NaN. Calling toFixed only on the final total still accumulates floating-point error in the sum and is a display fix rather than a calculation fix. Changing the upstream parser violates the constraint to leave it untouched. Concatenating strings with the plus operator produces a joined string that parseFloat reads only as the first number, giving a wrong total.
-
4 Question 4 Single choice Asynchronous Programming
A developer at a logistics company writes the following code in a browser module: console.log('start'); setTimeout(() => console.log('timeout'), 0); Promise.resolve().then(() => console.log('promise')); console.log('end'); The team wants to understand the order in which these messages appear in the console so they can reason about when pending shipment updates will be processed. Which output order is correct?
Correct Answer: BExplanationSynchronous code runs to completion first, so start and end print before anything queued. Promise callbacks are placed on the microtask queue, which drains before the next macrotask, so promise prints before the setTimeout callback, which sits in the task queue even with a zero delay. Printing timeout before promise ignores microtask priority, and placing timeout before end ignores that synchronous code always finishes first.
-
5 Question 5 Single choice Browser and Events
A retail storefront renders a product grid inside a container div. Each product card has a button that adds the item to a cart. The grid is rebuilt every time a filter changes, and the product list can contain several hundred cards. Engineers currently attach a click listener to every button after each render. Page responsiveness has degraded and memory usage climbs after repeated filtering. The team must keep the cart behaviour intact, avoid re-binding listeners on each render, and not change the markup of the cards. Which approach best meets these requirements?
Correct Answer: DExplanationEvent delegation relies on bubbling: one listener on the stable container receives clicks from all cards, and closest identifies the relevant button, so no per-render binding is needed and memory stays flat. Removing and re-adding listeners still rebinds on every render and is wasteful. Setting onclick in the loop also rebinds each card on each render. Calling stopPropagation prevents the container from ever seeing the event, which defeats delegation and breaks any other listeners.
-
6 Question 6 Single choice Debugging and Error Handling
A payments integration module calls an internal JSON parser inside a try block and then passes the result to a settlement function. During a nightly batch, a malformed record causes the parser to throw, but the batch continues and the failed record is silently recorded as settled with a zero amount. Auditors require that every failure remain visible, that the original error type and stack trace be preserved, and that the batch continue processing the remaining records. Which change best satisfies these constraints?
Correct Answer: CExplanationCatching the error and recording the full error object preserves the type and stack trace for auditors, while skipping the bad record lets the batch proceed. Logging only the message loses the stack trace and still fabricates a zero settlement. An empty catch hides the failure entirely, violating the visibility requirement. Moving the call outside the try block halts the whole batch, breaking the continuation requirement.
-
7 Question 7 Single choice Objects, Functions, and Classes
A healthcare scheduling app defines a Clinic class with a method that returns the list of available slots. The method is passed as a callback to a helper that invokes it without a receiver, and the method throws a TypeError reading 'slots' of undefined. A developer must fix the defect while keeping a single shared method definition for all Clinic instances and without changing the call site in the helper. Which change is most appropriate?
Correct Answer: BExplanationWhen a class method is extracted and called without a receiver, this is undefined in strict code. An arrow function class field captures this from the constructor, so the callback keeps the right instance, but it creates a per-instance function rather than a shared prototype method, which is an acceptable trade-off here only because the constraint is correctness. Using bind in the constructor is the equivalent alternative. Using a call at every call site violates the no-change constraint on the helper usage. An object literal loses the class design, and static removes the instance state entirely.
-
8 Question 8 Single choice Server Side JavaScript
A team builds a Node.js service that imports a shared validation library used by three internal packages. The CI pipeline must produce identical dependency trees on every build, the production image must not include development tooling, and the team must not allow automatic minor-version upgrades to change behaviour unexpectedly. The repository already contains a lock file generated by npm. Which command sequence best meets these requirements in the CI job?
Correct Answer: AExplanationnpm ci installs strictly from package-lock.json, failing if it is out of sync, which guarantees reproducible trees, and the omit dev flag excludes development dependencies from the production install. npm install with a later update can move versions, violating the reproducibility requirement. Deleting the lock file destroys the pinning that the team depends on. Global installation does not populate the project's node_modules for the service at all.
-
9 Question 9 Single choice Testing
A developer wrote a unit test for a function that calculates a discounted price. The function returns a number rounded to two decimals, and the test is intended to catch regressions in the rounding logic. function discounted(price, pct) { return Math.round(price * (1 - pct / 100) * 100) / 100; } test('discount is applied', () => { const result = discounted(20, 10); expect(result).toBeTruthy(); }); The team says the test passes even when the discount formula is badly broken. Which modification makes the test most effective?
Correct Answer: AExplanationA truthy check passes for any non-zero number, so a wrong formula that still returns a positive value slips through. Asserting the exact expected value 18 validates both the percentage math and the rounding step. Checking for undefined or the number type still allows incorrect numeric results to pass. Expecting no exception ignores the return value entirely, so it cannot detect wrong results.
-
10 Question 10 Single choice Variables, Types, and Collections
A finance dashboard reads a configuration value from a query string, where a discount threshold arrives as the string "0" when disabled and as a number when set by an admin tool. The developer writes if (threshold) { applyDiscount(); } to decide whether to apply a rule. Business users report that applyDiscount runs when the threshold is zero. The fix must keep string values from the query working and must treat only a real zero or an empty value as disabled. Which change is best?
Correct Answer: AExplanationStrings like "0" are truthy in JavaScript, so the original if check enables the rule whenever a zero arrives as text. Converting with Number handles the query string, and the explicit condition distinguishes a numeric zero from an enabled value, so the logic matches the business rule. Checking against undefined still treats "0" as enabled. Loose equality to false is unreliable because the string "0" is coerced differently, and the null check does not address the zero case at all.
-
11 Question 11 Multiple choice Browser and Events
A SaaS dashboard shows live metrics in a table that is updated by a WebSocket. Developers must use browser developer tools to investigate a bug where the DOM keeps growing and memory rises after the user navigates between two views. Which TWO actions are most effective for locating the cause? (Choose two.)
Correct Answer: A, CExplanationHeap snapshots comparing retained objects reveal detached DOM nodes and leaked closures that persist across navigation. The Event Listeners panel shows whether handlers accumulate on the same elements each time a view is rendered. Changing network throttling does not reveal retention, clearing the console does not affect DOM growth, and Quirks Mode is unrelated to memory retention.
-
12 Question 12 Multiple choice Variables, Types, and Collections
A logistics app receives a JSON response containing an array of shipment records, where each record has a weight string such as "12.5" and a dispatched field holding an ISO date string. The team must compute the total weight of shipments dispatched in the current month and display the list sorted by date, without mutating the original response object used elsewhere. Which TWO actions are required? (Choose two.)
Correct Answer: C, DExplanationWeights arrive as strings, so explicit numeric conversion is needed before reduce, otherwise the plus operator concatenates them. Sort mutates the array it is called on, so copying first with slice or spread protects the original response. Calling sort directly mutates the shared data, adding raw strings relies on coercion that only works when the first operand is numeric, and JSON stringify clones the data but is not required for this sort-and-sum task.
These are 12 of the 147 questions in the full JS-Dev-101 pack.
Get All 147 QuestionsGet all 147 questions & answers
Full access options for Salesforce JS-Dev-101
Self-study
PDF Version
- 147 actual exam questions
- Compatible with all devices
- Printable PDF format
- No download limits
- 90 days free updates
- 24/7 customer support
Best value
Bundle Pack
- Discounted PDF + online access
- 147 actual exam questions
- Both PDF and online practice test
- Free 90 days updates
- No download or practice limits
- 24/7 customer support
Exam simulation
Online Practice Test
- 147 actual exam questions
- Actual exam environment
- 90 days free updates
- Browser-based software
- 24/7 customer support
100% Money Back Guarantee
Your success comes first
At DumpsProvider, we give you a 100% money back guarantee on all of our exam dumps. For us, your success is the #1 priority and we are more than confident that our exam material will help you pass the JS-Dev-101 Exam (Salesforce Certified JavaScript Developer) on your very first attempt.
In a rare case, if you fail your exam, we will refund your amount without asking a single question.