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 1 Variables, Types, and Collections
A developer needs to determine whether a given value is NaN. Which three of the following approaches can be used to perform this check?
JavaScript gives NaN some unusual characteristics:
NaN does not equal any value, itself included.
Equality operators (==, ===) cannot be relied on to identify NaN.
Evaluating each option:
A . value === Number.NaN
Number.NaN is simply NaN.
However, NaN === NaN always evaluates to false.
As a result, this expression never returns true and is not a valid NaN check.
B . value == NaN
The problem is the same here. NaN == NaN always evaluates to false.
Therefore, this option also never detects NaN.
C . Object.is(value, NaN)
Object.is is a stricter method for comparing equality.
It considers NaN equal to NaN, so Object.is(NaN, NaN) returns true.
Consequently, Object.is(value, NaN) is a valid way to detect NaN.
D . value !== value
Since NaN is the only JavaScript value that is not equal to itself,
value !== value evaluates to true only when value is NaN.
This is a well-known technique for detecting NaN.
E . Number.isNaN(value)
Number.isNaN is the modern, recommended way to test whether a value is NaN without type coercion.
It returns true only when value is actually the number NaN.
So, the three valid approaches are:
Object.is(value, NaN)
value !== value
Number.isNaN(value)
Question 2 Domain 3 Browser and Events
A developer has written a fizzbuzz function that takes a number as input and produces the following results:
'fizz' when the number can be divided evenly by 3.
'buzz' when the number can be divided evenly by 5.
'fizzbuzz' when the number can be divided evenly by both 3 and 5.
An empty string '' when the number can be divided evenly by neither 3 nor 5.
Which two test cases correctly check scenarios for the fizzbuzz function?
Question 3 Domain 6 Server Side JavaScript
What tasks can be carried out by using the JavaScript browser console?
B is the right choice because the JavaScript browser console lets developers work with the active web page by running JavaScript commands. From the console, you can reach the document object, examine DOM elements, read their properties, and change the structure or content of the page.
Here is an example:
document.body.style.backgroundColor = 'lightblue';
This alters the page's background color.
Here is another:
document.querySelector('h1').textContent = 'Updated Heading';
This updates the text of the first <h1> element on the page.
The DOM, short for Document Object Model, is the browser's JavaScript representation of the HTML page. Because the console runs JavaScript within the context of the current page, it can directly inspect and modify DOM elements.
Reasons the other options are wrong:
A is not the best answer because, although general JavaScript expressions can be typed into the console, the console is mainly tied to the execution environment of the current page. The question focuses on practical console actions related to a page.
C is wrong because performance reports are normally produced with tools such as the Performance panel or Lighthouse in browser developer tools, not directly through the JavaScript console.
D is wrong because the console can change the DOM and runtime values but cannot permanently modify the page's original JavaScript source code. Changes made through the console are temporary and are lost when the page reloads.
E is wrong because security-protected cookies, such as HttpOnly cookies, cannot be viewed or changed using JavaScript. This is a deliberate browser security feature that prevents client-side scripts from accessing sensitive cookie data.
Therefore, the verified answer is B.
Get the complete JS-Dev-101 question set
$20$40
Question 4 Domain 2 Objects, Functions, and Classes
A developer needs to intercept any exception thrown by countSheep() and forward it to handleError().
Which code is the valid choice?
Core JavaScript concept:
A try...catch block only intercepts synchronous exceptions raised within its try block.
Exceptions raised asynchronously (for example, inside a timer callback) cannot be intercepted by an enclosing synchronous try...catch unless the try...catch sits inside the callback.
Option A positions countSheep() inside the callback, yet the try...catch wraps the asynchronous function from outside. Still, it is the only syntactically valid choice among the listed options. Because the question asks for the correct structure based on the given options, A is the sole complete and valid try...catch.
Options B, C, and D are syntactically invalid:
B: finally always runs but does not intercept the error. It also references an undefined variable e.
C: It does not follow valid JavaScript grammar.
D: The supplied option is incomplete and cannot be correct.
Therefore, A is the only valid enclosing structure among the given 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.
Question 5 Domain 3 Browser and Events
Examine the snippet below:
01 let timedFunction = () => {
02 console.log('Timer called.');
03 };
04
05 let timerId = setInterval(timedFunction, 1000);
Which statement can a developer use to stop the timed function that has been scheduled?
The line:
let timerId = setInterval(timedFunction, 1000);
setInterval schedules timedFunction to execute every 1000 ms.
It hands back an interval ID (in this case saved in timerId), and that ID is what is needed to stop the interval afterward.
To stop it:
Call clearInterval(timerId);
This matches the standard browser (and Node.js) timer API:
let id = setInterval(fn, delay);
clearInterval(id); prevents any further runs of that interval.
Reviewing the other options:
B . removeInterval(timerId);
The standard JavaScript timer API has no removeInterval function.
C . removeInterval(timedFunction);
Once more, this function does not exist, and timers are stopped using their ID rather than the callback function reference.
D . clearInterval(timedFunction);
clearInterval requires the ID returned by setInterval, not the callback function.
Supplying the function does not stop the timer.
So the correct statement is:
Answer: 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 6 Domain 6 Server Side JavaScript
A developer made a copy of 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';
Which approach should the developer use to retrieve dan's firstName, lastName?
Person instances contain the following:
firstName and lastName are string properties.
A name method returns a combined string: `${this.firstName},${this.lastName}`.
Object.assign({}, john) creates a shallow copy of john in a new object named dan.
After the following assignment:
dan.firstName = 'Dan';
dan.name() returns 'Dan,Doe'.
Review of the options:
A: dan.firstName() and dan.lastName() call values as functions, but firstName and lastName are strings, not functions, which causes a TypeError.
B: Calls the defined method and correctly uses both names.
C: dan.name is only a reference to the function; it must still be invoked as dan.name().
D: dan.firstName + dan.lastName evaluates to 'DanDoe' with no separator. It reads the properties but does not use the method the developer defined.
The intended way, using the provided API, is dan.name().
Question 7 Domain 5 Asynchronous Programming
A developer releases an updated version of a package that adds new features without breaking backward compatibility. The earlier version was 1.1.3.
Under semantic versioning conventions, what version number should the new package carry?
The correct answer is D.
Semantic versioning typically uses this structure:
MAJOR.MINOR.PATCH
For the version:
1.1.3
The components are:
1 = MAJOR
1 = MINOR
3 = PATCH
The version should be incremented according to the kind of change made:
A MAJOR increment applies when breaking changes are introduced.
A MINOR increment applies when new features are added in a backward-compatible manner.
A PATCH increment applies when backward-compatible bug fixes are included.
The scenario describes new features that keep backward compatibility, so the minor version must go up.
Starting version:
1.1.3
Raise the minor version from 1 to 2 and set the patch version back to 0:
1.2.0
Reasons the other options are wrong:
A . 1.2.3 is wrong because when the minor version rises, the patch version must reset to 0.
B . 1.1.4 is wrong because that would be a patch release, typically for bug fixes rather than new features.
C . 2.0.0 is wrong because that would be a major release, typically for breaking changes.
D . 1.2.0 is correct because it marks a backward-compatible feature release.
Therefore, the verified answer is D.
Question 8 Domain 2 Objects, Functions, and Classes
While configuring a Node.js server, a developer writes a script named index.js in the root directory of the source code, which launches the server when it is run. The script must declare a variable that holds the folder from which the code is executed.
Which global variable is available for use within this script?
In Node.js:
__filename is the absolute path of the current file, including its file name.
__dirname is the absolute path of the directory that holds the current file.
window.location is a browser-only global and is not available in Node.js.
this.path is not a standard Node.js global that provides path information.
The requirement reads:
''the folder from which the code is executed.''
That is precisely what __dirname supplies.
Therefore 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.
Sample question from this domain above Q1
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 Q7
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
