Last Updated On : 29-Jun-2026


Salesforce Certified JavaScript Developer - JS-Dev-101 Practice Test

Prepare with our free Salesforce Certified JavaScript Developer - JS-Dev-101 sample questions and pass with confidence. Our Salesforce-JavaScript-Developer practice test is designed to help you succeed on exam day.

271 Questions
Salesforce 2026

Original constructor function:

01 function Vehicle(name, price) {

02 this.name = name;

03 this.price = price;

04 }

05 Vehicle.prototype.priceInfo = function () {

06 return `Cost of the $(this.name) is $(this.price)$`;

07 }

08 var ford = new Vehicle( ' Ford Fiesta ' , ' 20,000 ' );

Which class definition is correct?

A. class Vehicle {
constructor(name, price) {
this.name = name;
this.price = price;
}
priceInfo() {
return ' Cost of the ${this.name} is ${this.price}$ ' ;
}
}

B. class Vehicle {
vehicle(name, price) {
this.name = name;
this.price = price;
}
priceInfo() {
return ' Cost of the ${this.name} is ${this.price}$ ' ;
}
}

C. class Vehicle {
constructor() {
this.name = name;
this.price = price;
}
priceInfo() {
return `Cost of the ${this.name} is ${this.price}$`;
}
}

D. class Vehicle {
constructor(name, price) {
this.name = name;
this.price = price;
}
priceInfo() {
return `Cost of the ${this.name} is ${this.price}$`;
}
}

D.   class Vehicle {
constructor(name, price) {
this.name = name;
this.price = price;
}
priceInfo() {
return `Cost of the ${this.name} is ${this.price}$`;
}
}

Given the code below:

01 function Person() {

02 this.firstName = ' John ' ;

03 }

04

05 Person.proto = {

06 job: x = > ' Developer '

07 });

08

09 const myFather = new Person();

10 const result = myFather.firstName + ' ' + myFather.job();

What is the value of result when line 10 executes?

A. Error: myFather.job is not a function

B. undefined Developer

C. John Developer

D. John undefined

A.   Error: myFather.job is not a function

Given the JavaScript below:

function onLoad() {

console.log( " Page has loaded! " );

}

Where can the developer see the log statement after loading the page in the browser?

A. On the browser JavaScript console

B. On the terminal console running the web server

C. In the browser performance tools log

D. On the webpage console log

A.   On the browser JavaScript console

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 .

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 --save 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 --add when adding the dependency.

C.   The developer added the dependency as a dev dependency, and NODE_ENV is set to production.

Explanation:
Yarn respects the NODE_ENV environment variable during installation. When NODE_ENV=production, running yarn install (or yarn) skips installing packages listed in devDependencies. If the developer added the date manipulation library as a devDependency (using yarn add --dev), team members with NODE_ENV=production will not download it.

Correct Option:

C: The developer added the dependency as a dev dependency, and NODE_ENV is set to production.
devDependencies are intended for development tools (testing, linting, building). When NODE_ENV=production, Yarn (and npm) skip devDependencies to reduce installation size in production environments. The team likely has NODE_ENV=production set, preventing download of the date library.

Incorrect Option:

A: The developer added the dependency as a dev dependency, and YARN_ENV is set to production.
YARN_ENV is not a standard environment variable that controls devDependencies skipping. Yarn uses NODE_ENV for this behavior. YARN_ENV has no documented effect on dependency installation.

B: The developer missed the option --save when adding the dependency.
In Yarn (modern versions), yarn add automatically saves to dependencies by default. The --save flag is optional and legacy. Missing --save would not cause this issue; the dependency would still be saved correctly.

D: The developer missed the option --add when adding the dependency.
There is no --add flag in Yarn. The command is yarn add . The developer successfully added the dependency (pushed updates), so the command used was correct. The issue is installation behavior, not addition syntax.

Reference:
Yarn Documentation – "Installing Dependencies": When NODE_ENV=production, yarn install does not install packages listed in devDependencies. Use yarn install --production explicitly or set NODE_ENV=production to achieve this behavior.

Original code:

01 let requestPromise = client.getRequest;

03 requestPromise().then((response) = > {

04 handleResponse(response);

05 });

The developer wants to gracefully handle errors from a Promise-based GET request.

Which code modification is correct?

A. try/catch around requestPromise().then(...)

B. (duplicate of A)

C. Add .catch to the Promise chain

D. Use finally handler for errors

C.   Add .catch to the Promise chain

Explanation:
Promises provide a .catch() method to handle rejections (errors) gracefully. Adding .catch() to the Promise chain ensures that any error from requestPromise() or from within the .then() callback is caught and handled without crashing the application. This is the standard pattern for Promise error handling.

Correct Option:

C: Add .catch to the Promise chain
Modify the code to:
requestPromise().then((response) => { handleResponse(response); }).catch((error) => { console.error(error); });
The .catch() method attaches a rejection handler. If the Promise rejects or an error is thrown in .then(), the .catch() callback executes, allowing graceful error handling.

Incorrect Option:

A: try/catch around requestPromise().then(...)
try-catch only catches synchronous errors. Promises are asynchronous; errors from a rejected Promise cannot be caught by a try-catch block surrounding the Promise creation or .then() call. This would not work.

B: (duplicate of A)
Same as A. Invalid for asynchronous Promise rejection handling.

D: Use finally handler for errors
.finally() runs regardless of resolution or rejection, but it does not receive the error object. It is used for cleanup (e.g., hiding loading spinners), not for handling or logging errors. Errors would remain unhandled if only .finally() is used.

Reference:
MDN Web Docs – "Promise.prototype.catch()": The .catch() method returns a Promise and handles rejections. It is the recommended way to manage errors in Promise chains. try-catch cannot catch asynchronous Promise rejections without async/await. Use .finally() for cleanup, not error handling.

Salesforce-JavaScript-Developer Exam Questions - Home Previous
Page 6 out of 55 Pages