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

Free Salesforce JavaScript-Developer-I Practice Exam with Questions & Answers | Set: 4

Questions 31

Refer to the code below:

01 new Promise((resolve, reject) = > {

02 const fraction = Math.random();

03 if (fraction > 0.5) reject( ' fraction > 0.5, ' + fraction);

04 resolve(fraction);

05 })

06 .then(() = > console.log( ' resolved ' ))

07 .catch((error) = > console.error(error))

08 .finally(() = > console.log( ' when am I called? ' ));

When does Promise.finally on line 08 get called?

Options:
A.

When rejected

B.

When resolved and settled

C.

When resolved

D.

When resolved or rejected

Salesforce JavaScript-Developer-I Premium Access
Questions 32

Refer to the code below:

01 < html lang= " en " >

02 < table onclick= " console.log( ' Table log ' ); " >

03 < tr id= " row1 " >

04 < td > Click me! < /td >

05 < /tr >

06 < /table >

07 < script >

08 function printMessage(event) {

09 console.log( ' Row log ' );

10 event.stopPropagation();

11 }

12

13 let elem = document.getElementById( ' row1 ' );

14 elem.addEventListener( ' click ' , printMessage, false);

15 < /script >

16 < /html >

Which code change should be done for the console to log the following when " Click me! " is clicked?

Row log

Table log

Options:
A.

Change line 14 to elem.addEventListener( ' click ' , printMessage, true);

B.

Remove lines 13 and 14

C.

Change line 10 to event.stopPropagation(false);

D.

Remove line 10

Questions 33

A developer wants to use a module called DatePrettyPrint.

This module exports one default function called printDate().

How can the developer import and use printDate()?

Options:
A.

import DatePrettyPrint() from ' /path/DatePrettyPrint.js ' ;

printDate();

B.

import DatePrettyPrint from ' /path/DatePrettyPrint.js ' ;

DatePrettyPrint.printDate();

C.

import printDate from ' /path/DatePrettyPrint.js ' ;

DatePrettyPrint.printDate();

D.

import printDate from ' /path/DatePrettyPrint.js ' ;

printDate();

Questions 34

Refer to the code below:

01 function myFunction(reassign) {

02 let x = 1;

03 var y = 1;

04

05 if (reassign) {

06 let x = 2;

07 var y = 2;

08 console.log(x);

09 console.log(y);

10 }

11

12 console.log(x);

13 console.log(y);

14 }

What is displayed when myFunction(true) is called?

Options:
A.

2 2 2 2

B.

2 2 1 2

C.

2 2 1 1

D.

2 2 undefined undefined

Questions 35

Which statement allows a developer to update the browser navigation history without a page refresh?

Options:
A.

window.customHistory.pushState(newStateObject, ' ' , null);

B.

window.history.createState(newStateObject, ' ' );

C.

window.history.pushState(newStateObject, ' ' , null);

D.

window.history.updateState(newStateObject, ' ' );

Questions 36

Refer to the following code:

01 let obj = {

02 foo: 1,

03 bar: 2

04 }

05 let output = []

06

07 for (let something of obj) {

08 output.push(something);

09 }

10

11 console.log(output);

What is the value of output on line 11?

Options:
A.

An error will occur due to the incorrect usage of the for_of statement on line 07.

B.

[1, 2]

C.

[ " foo " , " bar " ]

D.

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

Questions 37

static delay = async delay = > {

return new Promise(resolve = > {

setTimeout(resolve, delay);

});

};

static asyncCall = async () = > {

await delay(1000);

console.log(1);

};

console.log(2);

asyncCall();

console.log(3);

Assume delay and asyncCall are in scope as functions.

What is logged to the console?

Options:
A.

1 2 3

B.

1 3 2

C.

2 1 3

D.

2 3 1

Questions 38

Refer to the code below:

01 let total = 10;

02 const interval = setInterval(() = > {

03 total++;

04 clearInterval(interval);

05 total++;

06 }, 0);

07 total++;

08 console.log(total);

Considering that JavaScript is single-threaded, what is the output of line 08 after the code executes?

Options:
A.

11

B.

12

C.

10

D.

13

Questions 39

Console logging methods that allow string substitution:

Options:
A.

message

B.

log

C.

assert

D.

info

E.

error

Questions 40

Given the code below:

01 const delay = async delay = > {

02 return new Promise((resolve, reject) = > {

03 console.log(1);

04 setTimeout(resolve, delay);

05 });

06 };

07

08 const callDelay = async () = > {

09 console.log(2);

10 const yup = await delay(1000);

11 console.log(3);

12 };

13

14 console.log(4);

15 callDelay();

16 console.log(5);

What is logged to the console?

Options:
A.

4 2 1 5 3

B.

4 2 1 5 3

C.

1 4 2 3 5

D.

4 5 1 2 3

Certification Provider: Salesforce
Exam Name: Salesforce Certified JavaScript Developer (JS-Dev-101)
Last Update: Jul 6, 2026
Questions: 147