Key details for this exam, checked against the published exam outline
Each question shows the correct answer and an explanation of why it is right
Refer to the code:
01 const exec = (item, delay) =>
02 new Promise(resolve => setTimeout(() => resolve(item), delay));
03
04 async function runParallel() {
05 const [result1, result2, result3] = await Promise.all(
06 [exec('x', '100'), exec('y', '500'), exec('z', '100')]
07 );
08 return `parallel is done: ${result1}${result2}${result3}`;
09 }
Which two statements correctly execute runParallel()?
Facts about JavaScript Promises:
runParallel() is declared async, which means it always returns a Promise.
Promises are consumed using .then(), .catch(), and .finally().
There is no .done() method in native JavaScript Promises.
The async keyword cannot be placed before a function call (option A is invalid syntax).
Analysis of each option:
A . async runParallel().then(data);
Invalid syntax. async cannot prefix an expression.
B . Valid. Calls the function and attaches a .then() handler.
C . Invalid. .done() is not part of JavaScript Promise API.
D . Valid. Calls runParallel() and chains .then().
Therefore the correct answers are B and D.
JavaScript Knowledge Reference (text-only)
async functions return Promises.
Promises use .then() to retrieve resolved values.
.done() is not part of the standard Promise interface.
A developer initiates a server with the file server.js and adds dependencies in the source code's package.json that are required to run the server.
Which command should the developer run to start the server locally?
Comprehensive and Detailed Explanation From JavaScript/Node.js Knowledge:
In a Node.js project that uses package.json, you typically define a 'start' script:
{
'scripts': {
'start': 'node server.js'
}
}
Then you start the app with:
npm start
npm start:
Looks up the 'start' script in package.json.
Runs the command defined there (commonly node server.js).
This is the standard way to start a Node.js app with npm-managed dependencies.
Why others are incorrect:
A . node start
Tries to run a file named start with Node; does not use package.json scripts.
C . npm start server.js
npm start does not take the script filename as an argument in this way; it just runs the start script as defined.
D . start server.js
Not an npm or node command; on some shells it just tries to ''start'' a process but is not the standard Node/npm workflow.
Relevant concepts: package.json, npm scripts, npm start, Node entry file execution.
Refer to the code below:
let productSKU = '8675309';
A developer has a requirement to generate SKU numbers that are always 19 characters long, starting with 'sku', and padded with zeros.
Which statement assigns the value sku000000008675309?
We start with:
let productSKU = '8675309';
The requirement:
Final SKU string:
Length: 19 characters.
Starts with 'sku'.
Remaining characters are digits padded with zeros on the left (to reach total length).
We can use String.prototype.padStart and String.prototype.padEnd:
str.padStart(targetLength, padString)
If str.length < targetLength, it adds padString to the start until the length is targetLength.
str.padEnd(targetLength, padString)
Similar, but adds padString to the end.
We want a pattern like:
First, pad the numeric part out to a fixed length with zeros.
Then, pad to total length with 'sku' at the start.
Analyze Option B
productSKU = productSKU.padStart(16, '0').padStart(19, 'sku');
Step 1: productSKU.padStart(16, '0')
Initial productSKU is '8675309' (length 7).
After padStart(16, '0'), we pad zeros on the left to reach length 16.
We need 16 7 = 9 zeros:
Result after step 1:
productSKU === '0000000008675309' // length 16
Step 2: .padStart(19, 'sku')
Now productSKU has length 16.
We call padStart(19, 'sku'):
We need 19 16 = 3 extra characters.
The pad string 'sku' is exactly 3 characters, so it is added as-is at the start.
Result after step 2:
productSKU === 'sku0000000008675309' // length 19
This satisfies:
Length 19.
Starts with 'sku'.
Remaining characters are zeros plus the original digits, i.e. a zero-padded numeric section.
While the literal sample sku000000008675309 in the text has a slightly different count of zeros, Option B follows the requirement pattern:
3 characters of 'sku'
Numeric part padded with zeros to make 16 characters total for the numeric part
3 + 16 = 19 total characters
Option B matches the intended logic using padStart and padEnd.
Why the other options are incorrect
Option A:
productSKU = productSKU.padEnd(16, '0').padStart('sku');
padEnd(16, '0') produces '8675309000000000' (original number followed by zeros).
padStart('sku') is invalid usage:
padStart takes a numeric target length as the first argument, not a string.
Passing 'sku' as the first argument leads to type coercion that does not achieve the intended behavior.
This will not reliably produce the desired SKU.
Option C:
productSKU = productSKU.padEnd(16, '0').padStart(19, 'sku');
First padEnd(16, '0') from '8675309' gives '8675309000000000' (length 16, zeros at the end).
Then padStart(19, 'sku') adds 3 chars 'sku' at the front:
Result: 'sku8675309000000000'.
This string starts with 'sku', but the zeros are at the end of the digits, not padding the numeric part on the left as desired.
Option D:
productSKU = productSKU.padStart(19, '0').padStart('sku');
First padStart(19, '0') pads zeros at the left to make the length 19.
Then padStart('sku') again incorrectly uses a string where a numeric targetLength is required.
This will not produce the correct SKU format.
Therefore, the only option that correctly uses padStart to create a 16-character zero-padded numeric portion and then a 19-character string starting with 'sku' is:
Answe r: B
Reference / Study Guide concepts (no links):
String.prototype.padStart(targetLength, padString)
String.prototype.padEnd(targetLength, padString)
String length calculations
Left-padding numeric strings with zeros
Building prefixed identifiers with fixed total length
Value of:
true + 3 + '100' + null
The correct answer is A.
JavaScript evaluates the expression from left to right:
true + 3 + '100' + null
Step 1:
true + 3
In numeric addition, true is converted to:
1
So:
true + 3
becomes:
1 + 3
Result:
4
Step 2:
4 + '100'
Because one operand is a string, JavaScript performs string concatenation instead of numeric addition.
So:
4 + '100'
becomes:
'4100'
Step 3:
'4100' + null
Again, because one operand is already a string, JavaScript converts null into the string:
'null'
So the final result is:
'4100null'
Execution summary:
true + 3 + '100' + null
// 1 + 3 + '100' + null
// 4 + '100' + null
// '4100' + null
// '4100null'
Therefore, the verified answer is A.
A developer wants to create a simple image upload using the File API.
HTML:
JavaScript:
01 function previewFile() {
02 const preview = document.querySelector('img');
03 const file = document.querySelector('input[type=file]').files[0];
04 // line 4 code
05 reader.addEventListener("load", () => {
06 preview.src = reader.result;
07 }, false);
08 // line 8 code
09 }
Which code in lines 04 and 08 allows the selected local image to be displayed?
The File API in browsers provides the FileReader object to read file contents selected from <input type='file'>.
Important knowledge points:
new FileReader() creates a file-reading object.
.readAsDataURL(file) reads a file and produces a Base64 URL string.
The 'load' event fires when the file has finished reading.
reader.result contains the data URL after reading completes.
Therefore, the correct implementation must:
Create a FileReader instance:
const reader = new FileReader();
Call:
reader.readAsDataURL(file);
Use the load event handler to assign the image preview:
preview.src = reader.result;
Option B is the only option that matches valid JavaScript File API usage.
Option A is incorrect because File is not a constructor for reading files.
Option C is incorrect because URL.createObjectURL(file) must be assigned directly as a URL, not used with reader.result.
JavaScript Knowledge Reference (text-only)
The file-reading interface in browsers is FileReader.
readAsDataURL() loads files as Base64 data URLs.
The load event indicates when the reader has finished and reader.result is available.
147 questions covering all exam domains, starting from $20
Exam domains verified against: Official Salesforce JS-Dev-101 exam guide, last checked September 2026.
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.
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.
Sample question from this domain above: Q3
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.
Sample question from this domain above: Q1
Handle errors properly in code scenarios. Use the browser console and breakpoints to debug code and trace application behavior.
Apply asynchronous programming concepts including callbacks, promises, and async/await. Understand the event loop and how it controls execution flow and determines outcomes.
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.
Analyze unit tests alongside code blocks to identify where tests are ineffective. Modify tests to make them more effective at validating code reliability.
Common questions about the exam itself