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: 3

Questions 21

function myFunction() {

a = a + b;

var b = 1;

}

myFunction();

console.log(a);

console.log(b);

Which statement is correct?

Options:
A.

Line 02 throws a reference error, therefore line 03 is never executed.

B.

Both line 02 and 03 are executed, but the values printed are undefined.

C.

Both line 02 and 03 are executed, and the variables are hoisted.

D.

Line 08 outputs the variable, but line 09 throws an error.

Salesforce JavaScript-Developer-I Premium Access
Questions 22

Given the code below:

01 setTimeout(() = > {

02 console.log(1);

03 }, 1100);

04 console.log(2);

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

06 setTimeout(() = > {

07 reject(console.log(3));

08 }, 1000);

09 }).catch(() = > {

10 console.log(4);

11 });

12 console.log(5);

What is logged to the console?

Options:
A.

25341

B.

12435

C.

12534

D.

21435

Questions 23

Refer to the code below:

let inArray = [ [1, 2], [3, 4, 5] ];

Which two statements result in the array [1, 2, 3, 4, 5]?

(With corrected typing errors: usArray → inArray, .. → ....)

Options:
A.

[].concat(...inArray);

B.

[].concat.apply(inArray, [] );

C.

[].concat::...inArray();

D.

[].concat.apply({}, inArray);

Questions 24

Refer to the code below (assuming Promise.race is intended):

let cat3 = new Promise(resolve = >

setTimeout(resolve, 3000, " Cat 3 completes " )

);

Promise.race([cat1, cat2, cat3])

.then(value = > {

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

})

.catch(err = > {

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

});

(Assuming cat1 and cat2 are similar to earlier examples: cat2 resolves fastest.)

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

Options:
A.

Car 2 completed the race.

B.

Car 1 crashed on the race.

C.

Race is cancelled.

D.

Car 3 completed the race.

Questions 25

Refer to the code below:

01 const myFunction = arr = > {

02 return arr.reduce((result, current) = > {

03 return result + current;

04 }, 10);

05 }

What is the output of this function when called with an empty array?

Options:
A.

Returns 0

B.

Throws an error

C.

Returns NaN

D.

Returns 5 ← (Text here appears to be a typo; correct value is 10, see explanation.)

Questions 26

A developer wants to use a try...catch statement to catch any error that countSheep() may throw and pass it to a handleError() function.

What is the correct implementation of the try...catch?

Options:
A.

setTimeout(function() {

try {

countSheep();

} catch (e) {

handleError(e);

}

}, 1000);

B.

try {

countSheep();

} finally {

handleError(e);

}

C.

try {

countSheep();

} handleError (e){

catch(e);

}

D.

try {

setTimeout(function() {

countSheep();

}, 1000);

} catch (e) {

handleError(e);

}

Questions 27

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

Options:
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.

Questions 28

A developer has an isDeg function that takes one argument, pts. They want to schedule the function to run every minute.

What is the correct syntax for scheduling this function?

Options:
A.

setInterval(isDeg( ' cat ' ), 60000);

B.

setInterval(isDeg, 60000, ' cat ' );

C.

setTimeout(isDeg, 60000, ' cat ' );

D.

setTimeout(isDeg( ' cat ' ), 60000);

Questions 29

Value of:

true + 3 + ' 100 ' + null

Options:
A.

" 4100null "

B.

104

C.

" 4100 "

D.

" 2200null "

Questions 30

Refer to the code snippet:

01 function getAvailableilityMessage(item) {

02 if (getAvailableility(item)) {

03 var msg = " Username available " ;

04 }

05 return msg;

06 }

What is the return value of msg when getAvailableilityMessage( " newUserName " ) is executed and getAvailableility( " newUserName " ) returns false?

Options:
A.

" newUserName "

B.

" msg is not defined "

C.

undefined

D.

" Username available "

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