Pre-Summer Sale 70% Discount Offer - Ends in 0d 00h 00m 00s - Coupon code: best70

JavaScript-Developer-I Salesforce Certified JavaScript Developer (JS-Dev-101) Questions and Answers

Questions 4

Refer to the following code:

01 class Ship {

02 constructor(size) {

03 this.size = size;

04 }

05 }

06

07 class FishingBoat extends Ship {

08 constructor(size, capacity){

09 //Missing code

10 this.capacity = capacity;

11 }

12 displayCapacity() {

13 console.log( ' The boat has a capacity of ${this.capacity} people. ' );

14 }

15 }

16

17 let myBoat = new FishingBoat( ' medium ' , 10);

18 myBoat.displayCapacity();

Which statement should be added to line 09 for the code to display

The boat has a capacity of 10 people?

Options:

A.

super(size);

B.

ship.size = size;

C.

super.size = size;

D.

this.size = size;

Buy Now
Questions 5

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?

Options:

A.

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

B.

(duplicate of A)

C.

Add .catch to the Promise chain

D.

Use finally handler for errors

Buy Now
Questions 6

A developer has two ways to write a function:

Option A:

01 function Monster() {

02 this.growl = () = > {

03 console.log( " Grr! " );

04 }

05 }

Option B:

01 function Monster() {};

02 Monster.prototype.growl = () = > {

03 console.log( " Grr! " );

04 }

After deciding on an option, the developer creates 1000 monster objects. How many growl methods are created with Option A and Option B?

Options:

A.

1000 growl methods are created regardless of which option is used.

B.

1 growl method is created regardless of which option is used.

C.

1000 growl methods are created for Option A. 1 growl method is created for Option B.

D.

1 growl method is created for Option A. 1000 growl methods are created for Option B.

Buy Now
Questions 7

Given the code:

const copy = JSON.stringify([new String( ' false ' ), new Boolean(false), undefined]);

What is the value of copy?

Options:

A.

' [ " false " , false, null] '

B.

' [false, {}] '

C.

' [ " false " , false, undefined] '

D.

' [ " false " , {}] '

Buy Now
Questions 8

Given the JavaScript below:

01 function filterDOM(searchString){

02 const parsedSearchString = searchString & & searchString.toLowerCase();

03 document.querySelectorAll( ' .account ' ).forEach(account = > {

04 const accountName = account.innerHTML.toLowerCase();

05 account.style.display = accountName.includes(parsedSearchString) ? /* Insert code here */;

06 });

07 }

Which code should replace the placeholder comment on line 05 to hide accounts that do not match the search string?

Options:

A.

' block ' : ' none '

B.

' hidden ' : ' visible '

C.

' visible ' : ' hidden '

D.

' none ' : ' block '

Buy Now
Questions 9

Refer to the code below:

01 function changeValue(param) {

02 param = 5;

03 }

04 let a = 10;

05 let b = a;

06

07 changeValue(b);

08 const result = a + ' - ' + b;

What is the value of result when the code executes?

Options:

A.

5-5

B.

5-10

C.

10-5

D.

10-10

Buy Now
Questions 10

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()?

Options:

A.

async runParallel().then(data);

B.

runParallel().then(function(data){

return data;

});

C.

runParallel().done(function(data){

return data;

});

D.

runParallel().then(data);

Buy Now
Questions 11

Refer to the HTML below:

< div id= " main " >

< ul >

< li > Leo < /li >

< li > Tony < /li >

< li > Tiger < /li >

< /ul >

< /div >

Which JavaScript statement results in changing " Leo " to " The Lion " ?

Options:

A.

document.querySelectorAll( ' #main #Leo ' ).innerHTML = ' The Lion ' ;

B.

document.querySelector( ' #main li:second-child ' ).innerHTML = ' The Lion ' ;

C.

document.querySelectorAll( ' #main li,Leo ' ).innerHTML = ' The Lion ' ;

D.

document.querySelector( ' #main li:nth-child(1) ' ).innerHTML = ' The Lion ' ;

Buy Now
Questions 12

Refer to the code below:

01 const objBook = {

02 title: ' JavaScript ' ,

03 };

04 Object.preventExtensions(objBook);

05 const newObjBook = objBook;

06 newObjBook.author = ' Robert ' ;

What are the values of objBook and newObjBook respectively?

Options:

A.

{ title: " JavaScript " }

{ title: " JavaScript " }

B.

{ author: " Robert " , title: " JavaScript " }

undefined

C.

{ author: " Robert " }

{ author: " Robert " , title: " JavaScript " }

D.

{ author: " Robert " , title: " JavaScript " }

{ author: " Robert " , title: " JavaScript " }

Buy Now
Questions 13

Refer to the code below:

01 let country = {

02 get capital() {

03 let city = Number( " London " );

04

05 return {

06 cityString: city.toString(),

07 }

08 }

09 }

Which value can a developer expect when referencing country.capital.cityString?

Options:

A.

An error

B.

NaN

C.

undefined

D.

' London '

Buy Now
Questions 14

Given the following code:

01 counter = 0;

02 const logCounter = () = > {

03 console.log(counter);

04 };

05 logCounter();

06 setTimeout(logCounter, 2100);

07 setInterval(() = > {

08 counter++;

09 logCounter();

10 }, 1000);

What will be the first four numbers logged?

Options:

A.

0122

B.

0123

C.

0112

D.

0012

Buy Now
Questions 15

Refer to the code below:

let strNumber = ' 12345 ' ;

Which code snippet shows a correct way to convert this string to an integer?

Options:

A.

let numberValue = Integer(strNumber);

B.

let numberValue = textValue.toInteger();

C.

let numberValue = Number(strNumber);

D.

let numberValue = (number) textValue;

Buy Now
Questions 16

Which two implementations of utils.js support foo and bar?

Options:

A.

const foo = () = > { return ' foo ' ; };

const bar = () = > { return ' bar ' ; };

export { foo, bar };

B.

const foo = () = > { return ' foo ' ; };

const bar = () = > { return ' bar ' ; };

export default { foo, bar };

C.

import { foo, bar } from " ./helpers/utils.js " ;

export { foo, bar };

D.

export default class {

foo() { return ' foo ' ; }

bar() { return ' bar ' ; }

}

Buy Now
Questions 17

Console logging methods that allow string substitution:

Options:

A.

message

B.

log

C.

assert

D.

info

E.

error

Buy Now
Questions 18

A developer has a fizzbuzz function that, when passed in a number, returns the following:

    ' fizz ' if the number is divisible by 3.

    ' buzz ' if the number is divisible by 5.

    ' fizzbuzz ' if the number is divisible by both 3 and 5.

    Empty string ' ' if the number is divisible by neither 3 nor 5.

Which two test cases properly test scenarios for the fizzbuzz function?

Options:

A.

let res = fizzbuzz(true);

console.assert(res === ' ' );

B.

let res = fizzbuzz(3);

console.assert(res === ' ' );

C.

let res = fizzbuzz(5);

console.assert(res === ' fizz ' );

D.

let res = fizzbuzz(15);

console.assert(res === ' fizzbuzz ' );

Buy Now
Questions 19

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?

Options:

A.

productSKU = productSKU.padEnd(16, ' 0 ' ).padStart( ' sku ' );

B.

productSKU = productSKU.padStart(16, ' 0 ' ).padStart(19, ' sku ' );

C.

productSKU = productSKU.padEnd(16, ' 0 ' ).padStart(19, ' sku ' );

D.

productSKU = productSKU.padStart(19, ' 0 ' ).padStart( ' sku ' );

Buy Now
Questions 20

A developer is asked to fix some bugs reported by users. To do that, the developer adds a breakpoint for debugging.

01 function Car(maxSpeed, color) {

02 this.maxSpeed = maxSpeed;

03 this.color = color;

04 }

05 let carSpeed = document.getElementById( ' carSpeed ' );

06 debugger;

07 let fourWheels = new Car(carSpeed.value, ' red ' );

When the code execution stops at the breakpoint on line 06, which two types of information are available in the browser console?

Options:

A.

A variable displaying the number of instances created for the Car object

B.

The information stored in the window.localStorage property

C.

The values of the carSpeed and fourWheels variables

D.

The style, event listeners and other attributes applied to the carSpeed DOM element

Buy Now
Questions 21

Refer to the code:

01 console.log( ' Start ' );

02 Promise.resolve( ' Success ' ).then(function(value) {

03 console.log( ' Success ' );

04 });

05 console.log( ' End ' );

What is the output after the code executes successfully?

Options:

A.

Start

Success

End

B.

Start

End

Success

C.

End

Start

Success

D.

Success

Start

End

Buy Now
Questions 22

Which statement accurately describes the behavior of the async/await keywords?

Options:

A.

The associated function sometimes returns a promise.

B.

The associated function can only be called via asynchronous methods.

C.

The associated class contains some asynchronous functions.

D.

The associated function is asynchronous, but acts like synchronous code.

Buy Now
Questions 23

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?

Options:

A.

low

B.

10

C.

5

D.

undefined

Buy Now
Questions 24

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?

Options:

A.

5

undefined

B.

5

0

C.

true

false

D.

5

-1

Buy Now
Questions 25

Given the code below:

let numValue = 1982;

Which three code segments result in a correct conversion from number to string?

Options:

A.

let strValue = numValue.toText();

B.

let strValue = String(numValue);

C.

let strValue = ' ' + numValue;

D.

let strValue = numValue.toString();

E.

let strValue = (String)numValue;

Buy Now
Questions 26

Given the following code:

01 let x = null;

02 console.log(typeof x);

What is the output of line 02?

Options:

A.

" object "

B.

" undefined "

C.

" x "

D.

" null "

Buy Now
Questions 27

Refer to the following object:

const dog = {

firstName: ' Beau ' ,

lastName: ' Boo ' ,

get fullName() {

return this.firstName + ' ' + this.lastName;

}

};

How can a developer access the fullName property for dog?

Options:

A.

dog.fullName

B.

dog.fullName()

C.

dog.get.fullName

D.

dog.function.fullName()

Buy Now
Questions 28

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?

Options:

A.

node start

B.

npm start

C.

npm start server.js

D.

start server.js

Buy Now
Questions 29

Which statement accurately describes an aspect of promises?

Options:

A.

Arguments for the callback function passed to .then() are optional.

B.

.then() cannot be added after a catch.

C.

.then() manipulates and returns the original promise.

D.

In a .then() function, returning results is not necessary since callbacks will catch the result of a previous promise.

Buy Now
Questions 30

Considering type coercion, what does the following expression evaluate to?

true + ' 13 ' + NaN

Options:

A.

' true13NaN '

B.

' 113NaN '

C.

14

D.

' true13 '

Buy Now
Questions 31

A developer is required to write a function that calculates the sum of elements in an array but is getting undefined every time the code is executed. The developer needs to find what is missing in the code below.

01 const sumFunction = arr = > {

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

03 //

04 result += current;

05 //

06 }, 10);

07 };

Which line replacement makes the code work as expected?

Options:

A.

03 if(arr.length == 0) { return 0; }

B.

04 result = result + current;

C.

02 arr.map((result, current) = > {

D.

05 return result;

Buy Now
Questions 32

A developer wants to create a simple image upload using the File API.

HTML:

< input type= " file " onchange= " previewFile() " >

< img src= " " height= " 200 " alt= " Image preview... " / >

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?

Options:

A.

04 const reader = new File();

08 if (file) reader.readAsDataURL(file);

B.

04 const reader = new FileReader();

08 if (file) reader.readAsDataURL(file);

C.

04 const reader = new FileReader();

08 if (file) URL.createObjectURL(file);

Buy Now
Questions 33

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

Buy Now
Questions 34

Which two code snippets show working examples of a recursive function?

Options:

A.

const sumToTen = numVar = > {

if (numVar < 0)

return;

return sumToTen(numVar + 1);

};

B.

function factorial(numVar) {

if (numVar < 0) return;

if (numVar === 0) return 1;

return numVar - 1;

}

C.

const factorial = numVar = > {

if (numVar < 0) return;

if (numVar === 0) return 1;

return numVar * factorial(numVar - 1);

};

D.

let countingDown = function(startNumber) {

if (startNumber > 0) {

console.log(startNumber);

return countingDown(startNumber - 1);

} else {

return startNumber;

}

};

(Note: Option D is shown here with corrected syntax: lowercase return and matching parentheses.)

Buy Now
Questions 35

Refer to the code below:

const pi = 3.1415926;

What is the data type of pi?

Options:

A.

Number

B.

Float

C.

Double

D.

Decimal

Buy Now
Questions 36

Given the code below:

01 setCurrentUrl();

02 console.log( " The current URL is: " + url);

03

04 function setCurrentUrl() {

05 url = window.location.href;

06 }

What happens when the code executes?

Options:

A.

The url variable has global scope and line 02 throws an error.

B.

The url variable has global scope and line 02 executes correctly.

C.

The url variable has local scope and line 02 executes correctly.

D.

The url variable has local scope and line 02 throws an error.

Buy Now
Questions 37

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?

Options:

A.

String(var1).concat(var2)

B.

String.concat(var1 + var2)

C.

var1 + var2

D.

var1.toString() + var2.toString()

Buy Now
Questions 38

const str = ' Salesforce ' ;

Which two statements result in the word " Sales " ?

Options:

A.

str.substring(0, 5);

B.

str.substr(s, 5);

C.

str.substring(0, 5);

D.

str.substr(0, 5);

Buy Now
Questions 39

Why does second have access to variable a?

Options:

A.

Inner function ' s scope

B.

Outer function ' s scope

C.

Prototype Chain

D.

Hoisting

Buy Now
Questions 40

Corrected code:

let a = " * " ;

let b = " ** " ;

// x = 3;

console.log(a);

What is displayed when the code executes?

Options:

A.

ReferenceError: a is not defined

B.

*

C.

undefined

D.

null

Buy Now
Questions 41

Refer to the following object:

01 const cat = {

02 firstName: ' Fancy ' ,

03 lastName: ' Whiskers ' ,

04 get fullName(){

05 return this.firstName + ' ' + this.lastName;

06 }

07 };

How can a developer access the fullName property for cat?

Options:

A.

cat.fullName()

B.

cat.get.fullName

C.

cat.function.fullName()

D.

cat.fullName

Buy Now
Questions 42

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

Which implementation should be used?

Options:

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

Buy Now
Questions 43

Refer to the following code block (with corrected template literals using backticks):

01 class Animal {

02 constructor(name) {

03 this.name = name;

04 }

05

06 makeSound() {

07 console.log(`${this.name} is making a sound.`);

08 }

09 }

10

11 class Dog extends Animal {

12 constructor(name) {

13 super(name);

14 this.name = name;

15 }

16 makeSound() {

17 console.log(`${this.name} is barking.`);

18 }

19 }

20

21 let myDog = new Dog( ' Puppy ' );

22 myDog.makeSound();

What is the console output?

Options:

A.

> Uncaught ReferenceError

B.

> Undefined

C.

> Puppy is barking.

Buy Now
Questions 44

Refer to the code below:

flag();

function flag() {

console.log( ' flag ' );

}

const anotherFlag = () = > {

console.log( ' another flag ' );

}

anotherFlag();

What is result of the code block?

Options:

A.

The console logs only ' flag ' .

B.

An error is thrown.

C.

The console logs ' flag ' and then an error is thrown.

D.

The console logs ' flag ' and ' another flag ' .

Buy Now
Exam Name: Salesforce Certified JavaScript Developer (JS-Dev-101)
Last Update: May 30, 2026
Questions: 147

PDF + Testing Engine

$140

Testing Engine

$105

PDF (Q&A)

$90