Salesforce Certified JavaScript Developer Exam (JS-Dev-101) - Salesforce

Exam Questions

94%

Students found the real exam almost the same

1,057

Students passed this exam after ExamsQA Prep

95.1%

Average score during Real Exams at the Testing Centre

💡

Browse at least 50% questions to maximize your chances of passing

Free Preview Questions

Sample JS-Dev-101 Exam Questions & Explanations

Practice with real question formats, multiple choice options, and detailed answer explanations for Salesforce JS-Dev-101.

Question #1 Verified Q&A
A team at Universal Containers works on a big project and uses yarn to manage the project's dependencies. A developer added a dependency to manipulate dates and pushed the updates to the remote repository. The rest of the team complains that the dependency does not get downloaded when they execute yarn.<br />
<br />
What could be the reason for this?
A The developer added the dependency as a dev dependency, and YARN_ENV is set to production.
B The developer missed the option --add when adding the dependency.
C The developer added the dependency as a dev dependency, and NODE_ENV is set to production.
D The developer missed the option --save when adding the dependency.
Correct Answer: The developer added the dependency as a dev dependency, and NODE_ENV is set to production.
Explanation:
________________________________________ Comprehensive and Detailed Explanation From Exact Extract JavaScript Knowledge In JavaScript server-side development using Node.js, dependency management is typically handled through package managers such as npm or yarn. These tools categorize installed packages into: dependencies – required for running the application in any environment devDependencies – required only during development (testing tools, build tools, documentation generators, etc.)<br />
<br />
When a package is installed using:<br />
yarn add <package> --dev<br />
it is placed under the "devDependencies" section of package.json. ________________________________________ Behavior of Production Mode<br />
<br />
Node.js uses the environment variable:<br />
NODE_ENV=production<br />
<br />
When this environment variable is set to production, both npm and Yarn follow the standard Node.js convention and skip installing devDependencies. This is done to optimize production builds and reduce deployment size. This is a known and documented behavior in Node.js package management tools.<br />
<br />
Therefore, if: The developer added the date-manipulation library as a dev dependency, and Other team members execute yarn in an environment where NODE_ENV=production is set, then Yarn will not install that dependency because devDependencies are intentionally excluded in production mode. This explains the behavior described in the question. ________________________________________<br />
<br />
Why the Other Options Are Incorrect<br />
<br />
Option A: "YARN_ENV is set to production" is incorrect because Yarn does not use the variable YARN_ENV for dependency installation behavior. Node.js tools use NODE_ENV, not YARN_ENV.<br />
<br />
Option B: This is incorrect because Yarn automatically writes dependencies into package.json. Unlike older<br />
npm versions, there is no need for the --save flag.<br />
<br />
Option D:<br />
<br />
There is no such option as --add. The correct syntax is simply:<br />
yarn add <package> Missing an option that does not exist cannot be the cause. ________________________________________ JavaScript Knowledge Reference (Text-Based, No Links) Node.js uses the environment variable NODE_ENV to determine production or development mode.<br />
Package managers (npm and Yarn) follow the rule that when NODE_ENV=production, only<br />
"dependencies" are installed and "devDependencies" are skipped.<br />
Yarn automatically persists installed packages to package.json without requiring --save.<br />
Yarn uses the command yarn add to add dependencies; there is no --add flag.
Question #2 Verified Q&A
Refer to the code below:<br />
01 let o = {<br />
02 get js() {<br />
03 let city1 = String('St. Louis');<br />
04 let city2 = String('New York');<br />
05<br />
06 return {<br />
07 firstCity: city1.toLowerCase(), 08 secondCity: city2.toLowerCase(),<br />
09 }<br />
10 }<br />
11 }<br />
<br />
What value can a developer expect when referencing o.js.secondCity?
A undefined
B 'new york'
C 'New York'
D An error
Correct Answer: 'new york'
Explanation:
________________________________________ Comprehensive and Detailed Explanation From Exact Extract JavaScript Knowledge<br />
<br />
1. Getter Functions in JavaScript<br />
In JavaScript, when an object uses the get keyword, it defines a getter method. Accessing a getter property executes the function and returns its value. Thus: o.js does not return the getter function; instead, it executes the function located at:<br />
get js() { ... }<br />
and returns the object inside the return block. ________________________________________<br />
<br />
2. Behavior of String() and toLowerCase()<br />
<br />
Inside the getter:<br />
let city1 = String('St. Louis');<br />
let city2 = String('New York');<br />
String() creates a string value.<br />
<br />
Then, the returned object is constructed as:<br />
{<br />
firstCity: city1.toLowerCase(), secondCity: city2.toLowerCase(),<br />
}<br />
The method toLowerCase() is a standard JavaScript string method that returns a new string with all alphabetic characters converted to lowercase.<br />
<br />
Therefore: city2.toLowerCase() returns: 'new york' ________________________________________<br />
<br />
3. Referencing the Property<br />
<br />
When the developer writes: o.js.secondCity the following happens: The getter js runs and returns an object.<br />
<br />
The returned object includes the property: secondCity: 'new york' Accessing .secondCity retrieves the lowercase string 'new york'. Therefore, the correct value is 'new york'. ________________________________________<br />
<br />
Why the Other Options Are Incorrect A . undefined – incorrect because the property secondCity clearly exists in the returned object. B . An error – incorrect because no invalid operations occur; all methods and properties are valid. C . 'New York' – incorrect because toLowerCase() transforms the string to lowercase. ________________________________________ JavaScript Knowledge Reference (Text-Based) Getter methods using the get keyword return computed values when accessed. JavaScript String values support the toLowerCase() method, which returns a lowercase version of the original string. Accessing nested properties like o.js.secondCity triggers the getter, returning the constructed object.
Question #3 Verified Q&A
Refer to the code below:<br />
01 x = 3.14;<br />
02<br />
03 function myFunction() {<br />
04 'use strict';<br />
05 y = x;<br />
06 }<br />
07<br />
08 z = x;<br />
09 myFunction();<br />
Considering the implications of 'use strict' on line 04, which three statements describe the execution of the code?
A Line 05 throws an error.
B 'use strict' is hoisted, so it has an effect on all lines.
C 'use strict' has an effect only on line 05.
D 'use strict' has an effect between line 04 and the end of the file.
E z is equal to 3.14.
Correct Answer: Line 05 throws an error., 'use strict' has an effect only on line 05., z is equal to 3.14.
Explanation:
Comprehensive and Detailed Explanation From Exact Extract JavaScript knowledge: Behavior of non-strict global code The script does not begin with a 'use strict' directive at the top level, so the global code (outside any function) runs in non-strict (sloppy) mode.<br />
Line 01: x = 3.14;<br />
In non-strict mode, assigning to an undeclared identifier (no var, let, or const) creates an implicit global variable. So after line 01, x exists and equals 3.14.<br />
Line 08: z = x;<br />
This also runs in non-strict mode. Since x is already defined (from line 01), z is set to 3.14. Therefore, statement B is correct: z is equal to 3.14. Scope of 'use strict' inside a function<br />
<br />
The line:<br />
'use strict';<br />
inside myFunction is a directive prologue for that function, not for the entire file. This means: Strict mode applies only within the body of myFunction, from the directive to the end of that function. It does not retroactively affect code before the function or code outside of it.<br />
<br />
Therefore: Statement A is incorrect: 'use strict' is not “hoisted” to affect the whole file. It only affects the function body. Statement C is incorrect: strict mode does not apply from line 04 to the end of the file; it only applies within myFunction, not to global lines like 01, 08, or 09. Execution of myFunction in strict mode<br />
<br />
When myFunction is called on line 09:<br />
function myFunction() {<br />
'use strict';<br />
y = x;<br />
}<br />
<br />
Within this function: Strict mode is active for its body. In strict mode, assigning to an undeclared variable (like y here) is not allowed and results in a ReferenceError at runtime.<br />
<br />
So line 05:<br />
y = x;<br />
throws a ReferenceError because y is not declared with var, let, or const. Therefore, statement E is correct: line 05 throws an error.<br />
<br />
Why statement D is considered correct<br />
<br />
Statement D says: 'use strict' has an effect only on line 05.<br />
<br />
In terms of execution in this specific code: The only executable statement in myFunction that is affected by strict mode is the assignment on line 05. The directive itself on line 04 is not a “normal” runtime operation; it is a directive that sets the mode. There are no other statements inside the function that behave differently under strict mode; only the line that assigns to the undeclared variable shows a strict-mode effect. So, describing the practical execution behavior of this snippet, strict mode manifests its effect only on line 05, making statement D correct in this context.<br />
<br />
Summary of each option: A: Incorrect – strict does not apply to all lines in the file. B: Correct – z becomes 3.14 in non-strict global code. C: Incorrect – strict does not affect code outside the function. D: Correct – in this code, the only behavioral effect of strict mode is on line 05. E: Correct – line 05 throws a ReferenceError due to assignment to undeclared y under strict mode.<br />
<br />
JavaScript knowledge references (descriptive, no links): In non-strict (sloppy) mode, assigning to an undeclared identifier creates a global variable. 'use strict' inside a function body enables strict mode for that function only. In strict mode, assigning to an undeclared variable results in a ReferenceError. Directive prologues ('use strict') affect only their containing function or script, not other scopes.<br />
==================================================
Question #4 Verified Q&A
Refer to the code below:<br />
01 let total = 10;<br />
02 const interval = setInterval(() => {<br />
03 total++;<br />
04 clearInterval(interval);<br />
05 total++;<br />
06 }, 0);<br />
07 total++;<br />
08 console.log(total);<br />
Considering that JavaScript is single-threaded, what is the output of line 08 after the code executes?
A 11
B 13
C 10
D 12
Correct Answer: 11
Explanation:
Comprehensive and Detailed Explanation From Exact Extract JavaScript knowledge: Synchronous execution order<br />
<br />
JavaScript executes code in a single thread, following a well-defined order: All synchronous code runs first, line by line. Asynchronous callbacks (like those scheduled with setInterval or setTimeout) are placed into the event queue and executed only after the current call stack is empty.<br />
<br />
Let’s follow the code step by step:<br />
<br />
Line 01:<br />
let total = 10;<br />
total is initialized with the value 10.<br />
<br />
Line 02:<br />
const interval = setInterval(() => {<br />
total++;<br />
clearInterval(interval);<br />
total++;<br />
}, 0);<br />
setInterval schedules the callback function to run repeatedly after a delay of at least 0 milliseconds, but it does not run immediately. The callback is added to the timer queue and will be invoked after the current synchronous script finishes and the event loop gets to process timer callbacks. At this point, interval holds the interval ID, but the callback has not executed yet.<br />
<br />
Line 07:<br />
total++;<br />
This is still synchronous, so it runs before any scheduled callbacks. total was 10, now it becomes 11.<br />
<br />
Line 08:<br />
console.log(total);<br />
At this moment, the interval callback has still not run (because the event loop has not yet processed the timer queue). So total is 11, and console.log(total); outputs 11. Therefore, the value printed at line 08 is 11, making option A correct.<br />
<br />
What happens after the log (for understanding, not affecting the answer)<br />
<br />
After the main script finishes, the event loop processes the timer callback for setInterval:<br />
<br />
Callback:<br />
() => {<br />
total++; // from 11 to 12<br />
clearInterval(interval); // cancels further executions<br />
total++; // from 12 to 13<br />
}<br />
So eventually total becomes 13, but this happens after console.log(total) has already executed. Since the question asks specifically for the output at line 08, the asynchronous updates do not change that line’s output.<br />
<br />
Why other options are incorrect<br />
<br />
Option B (12): This would require the callback to run before the log, which does not happen because asynchronous callbacks are queued and executed after the current stack finishes.<br />
<br />
Option C (10): Ignores the total++ on line 07.<br />
<br />
Option D (13): This is the final value after the callback finishes, but it occurs after the console.log line executes, not at the time line 08 runs.<br />
<br />
JavaScript knowledge references (descriptive, no links): JavaScript is single-threaded and uses an event loop with a call stack and task queues. setInterval schedules callbacks to run asynchronously after a minimum delay; the callback never runs before the current synchronous code finishes.<br />
Synchronous statements like total++ on line 07 execute before any queued interval callback.
Question #5 Verified Q&A
Refer to the code below:<br />
01 const objBook = {<br />
02 title: 'JavaScript',<br />
03 };<br />
04 Object.preventExtensions(objBook);<br />
05 const newObjBook = objBook;<br />
06 newObjBook.author = 'Robert';<br />
<br />
What are the values of objBook and newObjBook respectively?
A { title: "JavaScript" }<br /> { title: "JavaScript" }
B { author: "Robert", title: "JavaScript" }<br /> { author: "Robert", title: "JavaScript" }
C { author: "Robert", title: "JavaScript" }<br /> undefined
D { author: "Robert" }<br /> { author: "Robert", title: "JavaScript" }
Correct Answer: { title: "JavaScript" }<br /> { title: "JavaScript" }
Explanation:
________________________________________ Comprehensive and Detailed Explanation From Exact Extract JavaScript Knowledge Object.preventExtensions(obj) This built-in JavaScript method marks an object so that no new properties can be added to it. Existing properties can still be read and updated, but adding new ones is disallowed.<br />
const newObjBook = objBook;<br />
Both variables reference the same object in memory. JavaScript objects are assigned by reference, not copied.<br />
newObjBook.author = "Robert";<br />
Because the object has been marked as non-extensible, JavaScript will not allow new properties to be added.<br />
<br />
The behavior depends on mode: In non-strict mode: the assignment silently fails and does nothing. In strict mode: this would throw a TypeError. Since nothing indicates strict mode, this is non-strict behavior, making the assignment fail silently.<br />
<br />
Therefore, the object remains:<br />
{ title: "JavaScript" }<br />
Both objBook and newObjBook point to the same unchanged object. This matches option A. ________________________________________ JavaScript knowledge references (text-only) Object.preventExtensions() prevents adding new properties. Assigning an object to another variable copies the reference, not the object. Adding a property to a non-extensible object silently fails in non-strict mode.<br />
==================================================

Want to practice all 149 questions?

Practice under real exam conditions with instant grading, timed simulations, and community insights.

Start Full JS-Dev-101 Practice Test

Frequently Asked Questions

Common questions about the Salesforce JS-Dev-101 certification practice test

How many questions are in the Salesforce JS-Dev-101 practice exam on ExamsQA?
Our JS-Dev-101 (Salesforce Certified JavaScript Developer Exam) practice question bank currently includes 149 verified questions with comprehensive explanations.
Are the JS-Dev-101 exam practice questions up to date for 2026?
Yes, all Salesforce JS-Dev-101 practice questions are regularly updated and verified against current exam objectives.
Will the JS-Dev-101 practice questions help me pass on my first attempt?
The JS-Dev-101 (Salesforce Certified JavaScript Developer Exam) question bank is built to mirror the real exam's format and topics, with detailed explanations for every answer so you understand the reasoning — not just memorize responses.
Is there a free demo available for JS-Dev-101 Salesforce Certified JavaScript Developer Exam?
Yes, ExamsQA offers free demo questions for the JS-Dev-101 exam so you can test the interface and question quality before purchasing full access.