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.
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?
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?
A developer imports:
import printPrice from ' /path/PricePrettyPrint.js ' ;
What must be true about printPrice for this import to work?
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?
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?
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?
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?
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?
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?
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?
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?
What are two unique features of fat-arrow functions compared to normal function definitions?
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?
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?
01 function Monster() { this.name = ' hello ' ; };
02 const m = Monster();
What happens due to the missing new keyword?
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?
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?
Given the following code:
01 let x = null;
02 console.log(typeof x);
What is the output of line 02?
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?
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?
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?
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?
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
Given the code:
const copy = JSON.stringify([new String( ' false ' ), new Boolean(false), undefined]);
What is the value of copy?
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?
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?
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?
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?
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?
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?
Corrected code:
let a = " * " ;
let b = " ** " ;
// x = 3;
console.log(a);
What is displayed when the code executes?
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?
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 >
Given the code below:
let numValue = 1982;
Which three code segments result in a correct conversion from number to string?
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?
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?
