Summer Certification Sale Limited Time 65% Discount Offer - Ends in 0d 00h 00m 00s - Coupon code: pass65

Free Practice Questions for the Salesforce Developer JavaScript-Developer-I Exam (2026 Updated)

At Marks4sure, we are dedicated to providing IT professionals with the most accurate and reliable preparation materials for the Salesforce JavaScript-Developer-I exam. To support your certification journey, we have made a selection of our premium 2026 Salesforce Developer practice questions and answers available completely free. You can take this practice test as many times as you need. Every question includes a detailed, expertly verified explanation to ensure you fully grasp the core security concepts before test day.

Questions 4

A test searches for:

< button class= " blue " > Checkout < /button >

But the actual HTML is:

< button > Checkout < /button >

The test fails because it expects a class that no longer exists.

What type of test outcome is this?

Options:

A.

False negative

B.

True positive

C.

True negative

D.

False positive

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

import printPrice from ' /path/PricePrettyPrint.js ' ;

What must be true about printPrice for this import to work?

Options:

A.

printPrice must be a named export

B.

printPrice must be an all export

C.

printPrice must be the default export

D.

printPrice must be a multi export

Buy Now
Questions 7

Refer to the following code (correcting the missing template literal backticks):

let codeName = ' Bond ' ;

let sampleText = `The name is ${codeName}, Jim ${codeName}`;

A developer is trying to determine if a certain substring is part of a string.

Which three code statements return true?

Options:

A.

sampleText.includes( ' Jim ' );

B.

sampleText.includes( ' The ' , 1);

C.

sampleText.includes( ' Jim ' , 4);

D.

sampleText.indexOf( ' Bond ' ) !== -1;

E.

sampleText.substring( ' Jim ' );

Buy Now
Questions 8

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?

Options:

A.

speak

B.

owner

C.

canTalk

D.

name

E.

type

Buy Now
Questions 9

Refer to the code below:

01 let timedFunction = () = > {

02 console.log( ' Timer called. ' );

03 };

04

05 let timerId = setInterval(timedFunction, 1000);

Which statement allows a developer to cancel the scheduled timed function?

Options:

A.

clearInterval(timerId);

B.

removeInterval(timerId);

C.

removeInterval(timedFunction);

D.

clearInterval(timedFunction);

Buy Now
Questions 10

Code:

01 let array = [1, 2, 3, 4, 4, 5, 4, 4];

02 for (let i = 0; i < array.length; i++) {

03 if (array[i] === 4) {

04 array.splice(i, 1);

05 i--;

06 }

07 }

What is the value of array after execution?

Options:

A.

[1,2,3,4,5,4]

B.

[1,2,3,5]

C.

[1,2,3,4,5,4,4]

D.

[1,2,3,4,4,5,4]

Buy Now
Questions 11

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 12

A class was written to represent items for purchase in an online store, and a second class representing items that are on sale at a discounted price. The constructor sets the name to the first value passed in. There is a new requirement for a developer to implement a description method that will return a brief description for Item and SaleItem.

01 let regItem = new Item( ' Scarf ' , 55);

02 let saleItem = new SaleItem( ' Shirt ' , 80, .1);

03 Item.prototype.description = function() { return ' This is a ' + this.name; }

04 console.log(regItem.description());

05 console.log(saleItem.description());

06

07 SaleItem.prototype.description = function() { return ' This is a discounted ' + this.name; }

What is the output when executing the code above?

Options:

A.

This is a Scarf

Uncaught TypeError: saleItem.description is not a function

This is a Scarf

This is a discounted Shirt

B.

This is a Scarf

This is a Shirt

This is a Scarf

This is a discounted Shirt

C.

This is a Scarf

This is a Shirt

This is a discounted Scarf

This is a discounted Shirt

D.

This is a Scarf

Uncaught TypeError: saleItem.description is not a function

This is a Shirt

This is a discounted Shirt

Buy Now
Questions 13

A developer publishes a new version of a package with bug fixes but no breaking changes. The old version number was 2.1.1.

What should the new package version number be based on semantic versioning?

Options:

A.

2.1.2

B.

2.2.0

C.

2.2.1

D.

3.1.1

Buy Now
Questions 14

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 15

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 16

Refer to the code:

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

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

03 let car2 = new Promise(resolve = >

04 setTimeout(resolve, 1500, " Car 2 completed " ));

05 let car3 = new Promise(resolve = >

06 setTimeout(resolve, 3000, " Car 3 completed " ));

07

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

09 .then(value = > {

10 let result = ' $(value) the race. ' ;

11 })

12 .catch(err = > {

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

14 });

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

Options:

A.

Car 2 completed the race.

B.

Car 3 completed the race.

C.

Race is cancelled.

D.

Car 1 crashed in the race.

Buy Now
Questions 17

What are two unique features of fat-arrow functions compared to normal function definitions?

Options:

A.

If the function has a single expression in the function body, the expression will be evaluated and implicitly returned.

B.

The function uses the this from the enclosing scope.

C.

The function receives an argument called parentThis, giving the enclosing lexical scope.

D.

The function generates its own this making it useful for separating scope.

Buy Now
Questions 18

A developer uses a parsed JSON string to work with user information as in the block below:

01 const userInformation = {

02 " id " : " user-01 " ,

03 " email " : " user01@universalcontainers.demo " ,

04 " age " : 25

05 };

Which two options access the email attribute in the object?

Options:

A.

userInformation.email

B.

userInformation.get( " email " )

C.

userInformation[ " email " ]

D.

userInformation[email]

Buy Now
Questions 19

A developer is setting up a new Node.js server with a client library that is built using events and callbacks.

The library:

    Will establish a web socket connection and handle receipt of messages to the server.

    Will be imported with require, and made available with a variable called ws.

    The developer also wants to add error logging if a connection fails.

Given this information, which code segment shows the correct way to set up a client with two events that listen at execution time?

Options:

A.

ws.connect(() = > {

console.log( ' Connected to client ' );

}).catch((error) = > {

console.log( ' ERROR ' , error);

});

B.

ws.on( ' connect ' , () = > {

console.log( ' Connected to client ' );

});

ws.on( ' error ' , (error) = > {

console.log( ' ERROR ' , error);

});

C.

ws.on( ' connect ' , () = > {

console.log( ' Connected to client ' );

});

ws.on( ' error ' , (error) = > {

console.log( ' ERROR ' , error);

});

D.

try {

ws.connect(() = > {

console.log( ' Connected to client ' );

});

} catch(error) {

console.log( ' ERROR ' , error);

}

Buy Now
Questions 20

01 function Monster() { this.name = ' hello ' ; };

02 const m = Monster();

What happens due to the missing new keyword?

Options:

A.

The m variable is assigned the correct object.

B.

window.name is assigned to ' hello ' and the variable m remains undefined.

C.

window.m is assigned the correct object.

D.

The m variable is assigned the correct object but this.name remains undefined.

Buy Now
Questions 21

A developer wants to use a module named universalContainerslib and then call functions from it. How should a developer import every function from the module and then call the functions foo and bar?

Options:

A.

import * as lib from ' /path/universalContainerslib.js ' ;

lib.foo();

lib.bar();

B.

import * from ' /path/universalContainerslib.js ' ;

universalContainerslib.foo();

universalContainerslib.bar();

C.

import all from ' /path/universalContainerslib.js ' ;

universalContainerslib.foo();

universalContainerslib.bar();

D.

import {foo, bar} from ' /path/universalContainerslib.js ' ;

foo();

bar();

Buy Now
Questions 22

Console logging methods that allow string substitution:

Options:

A.

message

B.

log

C.

assert

D.

info

E.

error

Buy Now
Questions 23

A developer at Universal Containers creates a new landing page based on HTML, CSS, and JavaScript.

To ensure that visitors have a good experience, a script named personalizeWebsiteContent needs to be executed to do some custom initialization when the webpage is fully loaded with HTML content and all related files.

Which statement should be used to call personalizeWebsiteContent based on the above business requirement?

Options:

A.

document.addEventListener( ' DOMContentLoaded ' , personalizeWebsiteContent);

B.

document.addEventListener( ' onDOMContentLoaded ' , personalizeWebsiteContent);

C.

window.addEventListener( ' load ' , personalizeWebsiteContent);

D.

window.addEventListener( ' onload ' , personalizeWebsiteContent);

Buy Now
Questions 24

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 25

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 26

Most accurate tests for:

const arr = Array(5).fill(0);

Options:

A.

console.assert(arr.length === 0);

B.

console.assert(arr[5] === 0 & & arr.length === 0);

C.

arr.forEach(e = > console.assert(e === 0));

D.

console.assert(arr.length === 5);

Buy Now
Questions 27

A developer copied a JavaScript object:

01 function Person() {

02 this.firstName = " John " ;

03 this.lastName = " Doe " ;

04 this.name = () = > `${this.firstName},${this.lastName}`;

05 }

06

07 const john = new Person();

08 const dan = Object.assign({}, john);

09 dan.firstName = ' Dan ' ;

How does the developer access dan ' s firstName, lastName?

Options:

A.

dan.firstName() + dan.lastName()

B.

dan.name()

C.

dan.name

D.

dan.firstName + dan.lastName

Buy Now
Questions 28

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 29

A developer wrote the following code to test a sum3 function that takes in an array of numbers and returns the sum of the first three numbers in the array. The test passes:

01 let res = sum3([1, 2, 3]);

02 console.assert(res === 6);

03

04 res = sum3([1, 2, 3, 4]);

05 console.assert(res === 6);

A different developer made changes to the behavior of sum3 to instead sum all of the numbers present in the array.

Which two results occur when running the test on the updated sum3 function?

Options:

A.

The line 02 assertion fails.

B.

The line 05 assertion passes.

C.

The line 05 assertion fails.

D.

The line 02 assertion passes.

Buy Now
Questions 30

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

Buy Now
Questions 31

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 32

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 33

Refer to the code below:

01 async function functionUnderTest(isOK) {

02 if (isOK) return ' OK ' ;

03 throw new Error( ' not OK ' );

04 }

Which assertion accurately tests the above code?

Options:

A.

console.assert(await functionUnderTest(true), ' OK ' )

B.

console.assert(await (functionUnderTest(true), ' not OK ' ))

C.

console.assert(functionUnderTest(true), ' OK ' )

D.

console.assert(await functionUnderTest(true), ' not OK ' )

Buy Now
Questions 34

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?

Options:

A.

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

B.

assert(number + 2 === 0);

C.

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

D.

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

Buy Now
Questions 35

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

Buy Now
Questions 36

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 37

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
Questions 38

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 39

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 40

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 41

Refer to the following code:

< html lang= " en " >

< body >

< button class= " secondary " > Save draft < /button >

< button class= " primary " > Save and close < /button >

< /body >

< script >

function displaySaveMessage(event) {

console.log( ' Save message. ' );

}

function displaySuccessMessage(event) {

console.log( ' Success message. ' );

}

window.onload = function() {

document.querySelector( ' .secondary ' )

.addEventListener( ' click ' , displaySaveMessage, true);

document.querySelector( ' .primary ' )

.addEventListener( ' click ' , displaySuccessMessage, true);

}

< /script >

< /html >

Options:

A.

> Outer message

B.

> Outer message

Inner message

C.

> Inner message

D.

> Inner message

Outer message

Buy Now
Questions 42

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 43

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?

Options:

A.

Error: myFather.job is not a function

B.

undefined Developer

C.

John Developer

D.

John undefined

Buy Now
Questions 44

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 " ]

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

PDF + Testing Engine

$64.99   $185.69

Testing Engine

$49.99   $142.83

PDF (Q&A)

$54.99   $157.11