Salesforce JS-Dev-101 Practice Exam Questions & Answers
Salesforce JS-Dev-101 Exam Details
Key details for this exam, checked against the published exam outline
- Exam Code
- JS-Dev-101
- Full Name
- Salesforce Certified JavaScript Developer
- Issuing Body
- Salesforce
- Question Format (Our Bank)
- Multiple Choice
- Full Question Set
- 147 questions Get All Questions
Free JS-Dev-101 Practice Questions
Each question shows the correct answer and an explanation of why it is right
Question 1 Domain 3 Browser and Events
A developer has a fizzbuzz function that, when passed in a number, returns the following:
'fizz' if the number is divisible by 3.
'buzz' if the number is divisible by 5.
'fizzbuzz' if the number is divisible by both 3 and 5.
Empty string '' if the number is divisible by neither 3 nor 5.
Which two test cases properly test scenarios for the fizzbuzz function?
Question 2 Domain 6 Server Side JavaScript
Which actions can be done using the JavaScript browser console?
The correct answer is B because the JavaScript browser console allows developers to interact with the current web page using JavaScript commands. Through the console, you can access the document object, inspect DOM elements, read their properties, and modify the structure or content of the page.
For example:
document.body.style.backgroundColor = 'lightblue';
This changes the page's background color.
Another example:
document.querySelector('h1').textContent = 'Updated Heading';
This changes the text of the first <h1> element on the page.
The DOM, or Document Object Model, is the browser's JavaScript representation of the HTML page. Since the console runs JavaScript in the context of the current page, it can be used to inspect and modify DOM elements directly.
Why the other options are incorrect:
A is not the best answer because although you can type general JavaScript expressions in the console, the browser console is mainly connected to the current page's execution environment. The question is asking about practical browser-console actions related to a page.
C is incorrect because performance reports are usually generated through tools such as the Performance panel or Lighthouse in browser developer tools, not directly through the JavaScript console.
D is incorrect because the console can modify the DOM and runtime values, but it does not permanently change the original JavaScript source code of the page. Any changes made through the console are temporary and disappear when the page reloads.
E is incorrect because security-protected cookies, such as HttpOnly cookies, cannot be viewed or changed using JavaScript. This is an intentional browser security feature that prevents client-side scripts from accessing sensitive cookie data.
Therefore, the best verified answer is B.
Question 3 Domain 2 Objects, Functions, and Classes
A developer wants to catch any error that countSheep() may throw and pass it to handleError().
Which implementation is correct?
Key JavaScript knowledge:
try...catch catches synchronous errors that occur inside the try block.
Errors thrown asynchronously (e.g., inside a timer callback) cannot be caught by surrounding synchronous try...catch unless the try...catch is inside the callback.
Option A places countSheep() inside the callback but the try...catch is outside the asynchronous function. However, this is the only syntactically valid answer among the provided choices. Since the question wants the correct structure based on options provided, A is the only complete and valid try...catch.
Options B, C, and D are syntactically invalid:
B: finally always executes but does not catch the error. Also uses an undefined variable e.
C: Does not follow valid JavaScript grammar.
D: The provided option is incomplete and cannot be correct.
Thus, A is the only valid surrounding structure in the provided choices.
JavaScript Knowledge Reference (text-only)
try...catch syntax must be correctly structured.
finally does not catch errors.
try { } catch (e) { } is valid only when complete and correctly ordered.
Get the complete JS-Dev-101 question set
$20$40
Question 4 Domain 3 Browser and Events
Refer to the code below:
01 let timedFunction = () => {
02 console.log('Timer called.');
03 };
04
05 let timerId = setInterval(timedFunction, 1000);
Which statement allows a developer to cancel the scheduled timed function?
The code:
let timerId = setInterval(timedFunction, 1000);
setInterval schedules timedFunction to run every 1000 ms.
It returns an interval ID (here stored in timerId), which is used to cancel the interval later.
To cancel:
Use clearInterval(timerId);
This is the standard browser (and Node.js) API:
let id = setInterval(fn, delay);
clearInterval(id); stops future executions of that interval.
Check other options:
B . removeInterval(timerId);
There is no removeInterval function in the standard JavaScript timer API.
C . removeInterval(timedFunction);
Again, no such function; and timers are cancelled by ID, not by the callback function reference.
D . clearInterval(timedFunction);
clearInterval expects the ID returned by setInterval, not the callback function.
Passing the function does not cancel the timer.
Therefore, the correct statement is:
Answe r: A
Study Guide / Concept Reference (no links):
Timer APIs: setInterval and clearInterval
Relationship between timer ID and cancellation
Difference between interval ID and callback function
Basic async timing patterns in JavaScript
Question 5 Domain 6 Server Side JavaScript
A developer copied a JavaScript object:
01 function Person() {
02 this.firstName = "John";
03 this.lastName = "Doe";
04 this.name = () => `${this.firstName},${this.lastName}`;
05 }
06
07 const john = new Person();
08 const dan = Object.assign({}, john);
09 dan.firstName = 'Dan';
How does the developer access dan's firstName, lastName?
Person instances have:
firstName and lastName as string properties.
A name method that returns a combined string: `${this.firstName},${this.lastName}`.
Object.assign({}, john) creates a shallow copy of john into a new object, dan.
After:
dan.firstName = 'Dan';
dan.name() returns 'Dan,Doe'.
Analysis of options:
A: dan.firstName() and dan.lastName() are function calls, but firstName/lastName are strings, not functions TypeError.
B: Calls the defined method and uses both names correctly.
C: dan.name is a function reference; you'd still need to call it: dan.name().
D: dan.firstName + dan.lastName is 'DanDoe', no separator. It accesses the properties but not in the method the developer defined.
The intended way, using the provided API, is dan.name().
Question 6 Domain 5 Asynchronous Programming
A developer publishes a new version of a package with new features that do not break backward compatibility. The previous version number was 1.1.3.
Following semantic versioning formats, what should the new package version number be?
The correct answer is D.
Semantic versioning usually follows this format:
MAJOR.MINOR.PATCH
For the version:
1.1.3
The parts are:
1 = MAJOR
1 = MINOR
3 = PATCH
A package version should be updated based on the type of change:
MAJOR version changes when there are breaking changes.
MINOR version changes when new features are added in a backward-compatible way.
PATCH version changes when backward-compatible bug fixes are added.
The question says the developer added new features that do not break backward compatibility. That means the minor version should increase.
Starting version:
1.1.3
Increase the minor version from 1 to 2, and reset the patch version to 0:
1.2.0
Why the other options are incorrect:
A . 1.2.3 is incorrect because when the minor version increases, the patch version should reset to 0.
B . 1.1.4 is incorrect because that would represent a patch update, usually for bug fixes, not new features.
C . 2.0.0 is incorrect because that would represent a major version update, usually for breaking changes.
D . 1.2.0 is correct because it represents a backward-compatible feature release.
Therefore, the verified answe r is D.
Question 7 Domain 2 Objects, Functions, and Classes
A developer is setting up a Node.js server and is creating a script at the root of the source code, index.js, that will start the server when executed. The developer declares a variable that needs the folder location that the code executes from.
Which global variable can be used in the script?
In Node.js:
__filename is the absolute path to the current file (including file name).
__dirname is the absolute path to the directory that contains the current file.
window.location is a browser-only global, not available in Node.js.
this.path is not a standard Node.js global for path information.
The requirement is:
''the folder location that the code executes from.''
That is exactly what __dirname provides.
So the correct choice is __dirname.
Concepts: Node.js globals, __filename, __dirname, Node vs browser environment.
What the Salesforce JS-Dev-101 Exam Covers
Exam domains verified against the Official Salesforce JS-Dev-101 exam guide, last checked November 2026.
Domain 1 Variables, Types, and Collections
23%Write code to create and initialize variables correctly, working with strings, numbers, and dates. Demonstrate understanding of type coercion effects, truthy and falsey evaluations, array data manipulation, and JSON object operations.
Domain 2 Objects, Functions, and Classes
25%Apply object, function, and class implementations to meet business requirements. Understand how to use JavaScript modules and decorators, and analyze variable scope and execution flow within code blocks.
Domain 3 Browser and Events
17%Use events, event handlers, and event propagation to meet business requirements. Evaluate and manipulate the DOM, use browser developer tools to investigate code behavior, and work with browser specific APIs.
Domain 4 Debugging and Error Handling
7%Handle errors properly in code scenarios. Use the browser console and breakpoints to debug code and trace application behavior.
Domain 5 Asynchronous Programming
13%Apply asynchronous programming concepts including callbacks, promises, and async/await. Understand the event loop and how it controls execution flow and determines outcomes.
Sample question from this domain above Q6
Domain 6 Server Side JavaScript
8%Infer which Node.js implementation, CLI command, and library or framework fit a given scenario. Distinguish which Node.js package management solution is most appropriate and know the core Node.js modules.
Domain 7 Testing
7%Analyze unit tests alongside code blocks to identify where tests are ineffective. Modify tests to make them more effective at validating code reliability.
JS-Dev-101 Exam FAQ
Common questions about the exam itself
What background do I need before taking the JS-Dev-101 exam?
How long does it typically take to prepare for JS-Dev-101?
Which objective area is the hardest part of JS-Dev-101?
What is the exam format for JS-Dev-101?
Can I retake JS-Dev-101 if I fail?
How long is the JS-Dev-101 certification valid for?
What job role does the JS-Dev-101 certification prepare me for?
How does JS-Dev-101 relate to other Salesforce developer certifications?
Does JS-Dev-101 cover Lightning components?
What study resources does Salesforce provide for JS-Dev-101?
Other Salesforce Exams
Free practice questions for more Salesforce certification exams
