Salesforce JavaScript Developer I Practice Exams
Last updated on Nov 16,2026- Exam Code: JavaScript Developer I
- Exam Name: Salesforce Certified JavaScript Developer I
- Certification Provider: Salesforce
- Latest update: Nov 16,2026
A developer has a formatName function that takes two arguments, firstName and lastName and returns a string. They want to schedule the function to run once after five seconds.
What is the correct syntax toschedule this function?
- A . setTimeout (formatName(), 5000, "John", "BDoe");
- B . setTimeout (formatName(‘John’, ‘’Doe’), 5000);
- C . setTimout(() => { formatName("John’, ‘Doe’) }, 5000);
- D . setTimeout (‘formatName’, 5000, ‘John", "Doe’);
Refer to the code below:

What is the result when the Promise in the execute function is rejected?
- A . Resolved1 Resolved2 Resolved3Resolved4
- B . Rejected
- C . Rejected Resolved
- D . Rejected1 Rejected2 Rejected3 Rejected Rejected Rejected4
catch( arr => (
10 console.log(“Race is cancelled.”, err);
11 ));
What is the value of result when Promise.race executes?
- A . Car 3 completed the race.
- B . Car 1 crashed in the race.
- C . Car 2 completed the race.
- D . Race is cancelled.
A developer implements and calls the following code when an application state change occurs:
Const onStateChange =innerPageState) => {
window.history.pushState(newPageState, ‘ ’, null);
}
If the back button is clicked after this method is executed, what can a developer expect?
- A . A navigate event is fired with a state property that details the previous application state.
- B . The page isnavigated away from and the previous page in the browser’s history is loaded.
- C . The page reloads and all Javascript is reinitialized.
- D . A popstate event is fired with a state property that details the application’s last state.
A developer wants to create an object from a function in the browser using the code below:
Function Monster() { this.name = ‘hello’ };
Const z = Monster();
What happens due to lack of the new keyword on line 02?
- A . The z variable is assigned the correct object.
- B . The z variable is assigned the correct object but this.name remains undefined.
- C . Window.name is assigned to ‘hello’ and the variable z remains undefined.
- D . Window.m is assigned the correct object.
Consider type coercion, what does the following expression evaluate to?
True + 3 + ‘100’ + null
- A . 104
- B . 4100
- C . ‘3100null’
- D . ‘4100null’
myArraym can have one level, two levels, or more levels.
Which statement flattens myArray when it can be arbitrarily nested?
- A . myArray. reduce ((prev, curr) => prev.concat(curr) [ ]);
- B . myArray. join (",").split (",");
- C . [ ] .concat {. . .myArray) ;
- D . myArray.flat(Infinity);
A developer at Universal Containers is creating their 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 when the webpage is fully loaded (HTML content and all related files), in order to do some custom initializations.
Which implementation should be used to call Fe:s:-a;::eHec5;te::.-.ter.: based on the business requirement above?
- A . Add a listener to thewindow object to handle the DOMContentLoaded event
- B . Add a handler to the personalizeWebsiteContent script to handle the load event
- C . Add a listener to the window object to handle the lead event
- D . Add a handler to the personalizeWebsiteContent script tohandle the DOMContentLoaded event
Referto the code below:
new Promise((resolve, reject) => {
const fraction = Math.random();
if( fraction >0.5) reject("fraction > 0.5, " + fraction);
resolve(fraction);
})
.then(() =>console.log("resolved"))
.catch((error) => console.error(error))
.finally(() =>console.log(" when am I called?"));

When does Promise.finally on line 08 get called?
- A . When rejected
- B . When resolved and settled
- C . When resolved
- D . When resolved or rejected
A developer wrote 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 or 5.
Which two test cases will properly test scenarios for the fizzbuzz function? Choose 2 answers
- A . let res = fizzbuzz(5);console.assert (res === ‘ ’ );
- B . let res = fizzbuzz(15);console.assert (res === ‘ fizzbuzz ’ )
- C . let res = fizzbuzz(Infinity);console.assert (res === ‘ ’ )
- D . let res = fizzbuzz(3);console.assert (res === ‘ buzz ’ )