Summer Sale Special - Limited Time 70% Discount Offer - Ends in 0d 00h 00m 00s - Coupon code: xmaspas7

Easiest Solution 2 Pass Your Certification Exams

JavaScript-Developer-I Salesforce Certified JavaScript Developer (JS-Dev-101) Free Practice Exam Questions (2026 Updated)

Prepare effectively for your Salesforce JavaScript-Developer-I Salesforce Certified JavaScript Developer (JS-Dev-101) certification with our extensive collection of free, high-quality practice questions. Each question is designed to mirror the actual exam format and objectives, complete with comprehensive answers and detailed explanations. Our materials are regularly updated for 2026, ensuring you have the most current resources to build confidence and succeed on your first attempt.

Page: 2 / 3
Total 147 questions

A developer wrote the following code:

01 let x = object.value;

02

03 try {

04 handleObjectValue(x);

05 } catch(error) {

06 handleError(error);

07 }

The developer has a getNextValue function to execute after handleObjectValue(), but does not want to execute getNextValue() if an error occurs. How can the developer change the code to ensure this behavior?

A.

03 try {

04 handleObjectValue(x);

05 } catch(error) {

06 handleError(error);

07 } then {

08 getNextValue();

09 }

B.

03 try {

04 handleObjectValue(x);

05 getNextValue();

06 } catch(error) {

07 handleError(error);

08 }

C.

03 try {

04 handleObjectValue(x);

05 } catch(error) {

06 handleError(error);

07 }

08 getNextValue();

D.

03 try {

04 handleObjectValue(x);

05 } catch(error) {

06 handleError(error);

07 } finally {

08 getNextValue();

09 }

Corrected code:

let obj = {

foo: 1,

bar: 2

};

let output = [];

for (let something in obj) {

output.push(something);

}

console.log(output);

What is the output of line 11?

A.

[ " bar " , " foo " ]

B.

[1, 2]

C.

[ " foo " , " bar " ]

D.

[ " foo:1 " , " bar:2 " ]

A developer needs the function personalizeWebsiteContent to run when the webpage is fully loaded (HTML and all external resources).

Which implementation should be used?

A.

Add a handler to the personalizeWebsiteContent script to handle the DOMContentLoaded event

B.

Add a listener to the window object to handle the load event

C.

Add a listener to the window object to handle the DOMContentLoaded event

D.

Add a handler to the personalizeWebsiteContent script to handle the load event

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?

A.

node start

B.

npm start

C.

npm start server.js

D.

start server.js

01 function Animal(size, type) {

02 this.type = type || ' Animal ' ;

03 this.canTalk = false;

04 }

05

06 Animal.prototype.speak = function() {

07 if (this.canTalk) {

08 console.log( " It spoke! " );

09 }

10 };

11

12 let Pet = function(size, type, name, owner) {

13 Animal.call(this, size, type);

14 this.size = size;

15 this.name = name;

16 this.owner = owner;

17 }

18

19 Pet.prototype = Object.create(Animal.prototype);

20 let pet1 = new Pet();

Given the code above, which three properties are set for pet1?

A.

speak

B.

owner

C.

canTalk

D.

name

E.

type

A developer has a module that contains multiple functions.

What kind of export should be leveraged so that multiple functions can be used?

A.

multi

B.

default

C.

all

D.

named

JavaScript:

01 function Tiger() {

02 this.type = ' Cat ' ;

03 this.size = ' large ' ;

04 }

05

06 let tony = new Tiger();

07 tony.roar = () = > {

08 console.log( ' They\ ' re great! ' );

09 };

10

11 function Lion() {

12 this.type = ' Cat ' ;

13 this.size = ' large ' ;

14 }

15

16 let leo = new Lion();

17 // Insert code here

18 leo.roar();

Which two statements could be inserted at line 17 to enable line 18?

A.

leo.roar = () = > { console.log( ' They\ ' re pretty good! ' ); };

B.

Object.assign(leo, tony);

C.

Object.assign(leo, Tiger);

D.

leo.prototype.roar = () = > { console.log( ' They\ ' re pretty good! ' ); };

for (let number = 2; number < = 5; number += 1) {

// faster code statement here

}

Which statement meets the requirements to log an error when the Boolean statement evaluates to false?

A.

console.classy(number + 2 === 0);

B.

assert(number + 2 === 0);

C.

console.assert(number + 2 === 0);

D.

console.error(number + 2 === 0);

01 function changeValue(obj) {

02 obj.value = obj.value / 2;

03 }

04 const objA = {value: 10};

05 const objB = objA;

06

07 changeValue(objB);

08 const result = objA.value;

What is the value of result after the code executes?

A.

low

B.

10

C.

5

D.

undefined

Given the code below:

01 function Person(name, email) {

02 this.name = name;

03 this.email = email;

04 }

05

06 const john = new Person( ' John ' , ' john@email.com ' );

07 const jane = new Person( ' Jane ' , ' jane@email.com ' );

08 const emily = new Person( ' Emily ' , ' emily@email.com ' );

09

10 let usersList = [john, jane, emily];

Which method can be used to provide a visual representation of the list of users and to allow sorting by the name or email attribute?

A.

console.table(usersList);

B.

console.group(usersList);

C.

console.groupCollapsed(usersList);

D.

console.info(usersList);

Refer to the code below (corrected to use a template literal on line 08):

01 let car1 = new Promise((_, reject) = >

02 setTimeout(reject, 2000, " Car 1 crashed in " )

03 );

04 let car2 = new Promise(resolve = >

05 setTimeout(resolve, 1500, " Car 2 completed " )

06 );

07 let car3 = new Promise(resolve = >

08 setTimeout(resolve, 3000, " Car 3 completed " )

09 );

10

11 Promise.race([car1, car2, car3])

12 .then(value = > {

13 let result = `${value} the race.`;

14 })

15 .catch(err = > {

16 console.log( " Race is cancelled. " , err);

17 });

What is the value of result when Promise.race executes?

A.

Car 3 completed the race.

B.

Car 2 completed the race.

C.

Race is cancelled.

D.

Car 1 crashed in the race.

Refer to the code below:

01 const addBy = ?

02 const addByEight = addBy(8);

03 const sum = addByEight(50);

Which two functions can replace line 01 and return 58 to sum?

A.

const addBy = function(num1) {

return function(num2) {

return num1 + num2;

}

}

B.

const addBy = function(num1) {

return num1 * num2;

}

C.

const addBy = (num1) = > num1 + num2;

D.

(Corrected for typing errors)

const addBy = (num1) = > {

return function(num2) {

return num1 + num2;

}

}

const str = ' Salesforce ' ;

Which two statements result in the word " Sales " ?

A.

str.substring(0, 5);

B.

str.substr(s, 5);

C.

str.substring(0, 5);

D.

str.substr(0, 5);

Function to test:

01 const sum3 = (arr) = > {

02 if (!arr.length) return 0;

03 if (arr.length === 1) return arr[0];

04 if (arr.length === 2) return arr[0] + arr[1] ;

05 return arr[0] + arr[1] + arr[2];

06 };

Which two assert statements are valid tests for this function?

A.

console.assert(sum3([1, ' 2 ' ]) == 12);

B.

console.assert(sum3([ ' hello ' , 2, 3, 4]) === NaN);

C.

console.assert(sum3([-3, 2]) === -1);

D.

console.assert(sum3([0]) === 0);

Which option is true about the strict mode in imported modules?

A.

Add the statement use non-strict; before any other statements in the module to enable notstrict mode.

B.

Imported modules are in strict mode whether you declare them as such or not.

C.

Add the statement use strict = false; before any other statements in the module to enable notstrict mode.

D.

A developer can only reference notStrict() functions from the imported module.

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 developer wants to set up a secure web server with Node.js. The developer creates a directory locally called app-server, and the first file is app-server/index.js.

Without using any third-party libraries, what should the developer add to index.js to create the secure web server?

A.

const server = require( ' secure-server ' );

B.

const tls = require( ' tls ' );

C.

const http = require( ' http ' );

D.

const https = require( ' https ' );

Refer to the code below:

const searchText = ' Yay! Salesforce is amazing! ' ;

let result1 = searchText.search(/sales/i);

let result2 = searchText.search(/sales/);

console.log(result1);

console.log(result2);

After running this code, which result is displayed on the console?

A.

5

undefined

B.

5

0

C.

true

false

D.

5

-1

Refer to the code:

const pi = 3.1415926;

What is the data type of pi?

A.

Float

B.

Double

C.

Decimal

D.

Number

Given two expressions var1 and var2, what are two valid ways to return the concatenation of the two expressions and ensure it is data type string?

A.

String(var1).concat(var2)

B.

String.concat(var1 + var2)

C.

var1 + var2

D.

var1.toString() + var2.toString()

Page: 2 / 3
Total 147 questions
Copyright © 2014-2026 Solution2Pass. All Rights Reserved