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
Which code statement correctly retrieves and returns an object from localStorage?
- A . const retrieveFromLocalStorage = () =>{return JSON.stringify(window.localStorage.getItem(storageKey));}
- B . const retrieveFromLocalStorage = (storageKey) =>{return window.localStorage.getItem(storageKey);}
- C . const retrieveFromLocalStorage = (storageKey) =>{return JSON.parse(window.localStorage.getItem(storageKey));}
- D . constretrieveFromLocalStorage = (storageKey) =>{return window.localStorage[storageKey];}
Refer to the code below:
let car1 = new Promise((_,reject)=> setTimeout(reject,2000,"Car1 crashed in"));
let car2 = new Promise(resolve => setTimeout(resolve,1500,"Car2 completed"));
let car3 = new Promise(resolve => setTimeout(resolve,3000,"Car3 completed"));
Promise.race([car1,car2,car3])
.then(value=>{
let result = `${value} the race.`;
}).catch(err=>{
console.log(‘Race is cancelled.’,err);
});
What is the valueof result when promise.race execues?
- A . Car2 completed the race.
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 number in the array, The test passes:
Let res = sum2([1, 2, 3]);
console.assert(res === 6 );
Res = sum3([ 1, 2, 3, 4]);
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.
The test passes:
Which two results occur when running the test on the updated sum3 function? Choose 2 answers
- A . The line 02 assertion passes.
- B . The line 02 assertion fails
- C . The line 05 assertion passes.
- D . The line 05 assertion fails.
A developer wants to iterate through an array of objects and count the objects and count the objects whose property value, name, starts with the letterN.
Const arrObj = [{“name”: “Zach”}, {“name”: “Kate”},{“name”: “Alise”},{“name”: “Bob”},{“name”: “Natham”},{“name”: “nathaniel”}
Refer to the code snippet below:
01 arrObj.reduce(( acc, curr) => {
02 //missing line 02
02 //missing line 03
04 ). 0);
Which missing lines 02 and 03 return the correct count?
- A . Const sum = curr.startsWith(‘N’)? 1: 0;Return acc +sum
- B . Const sum = curr.name.startsWith(‘N’)? 1: 0;Return acc +sum
- C . Const sum = curr.startsWIth(‘N’)? 1: 0;Return curr+ sum
- D . Const sum =curr.name.startsWIth(‘N’)? 1: 0;Return curr+ sum
Which is a valid use of a Symbol in JavaScript?
- A . To add properties to an object that are not iterable.
- B . To create immediately invoked function expressions.
- C . To declare classes.
- D . All of the above.
A developer at Universal Containers is creating their new landing pagebased on HTML, CSS, and JavaScript. The website includes multiple external resources that are loaded when the page is opened.
To ensure that visitors have a good experience, a script named personalizeWebsiteContent needs to be executed when the webpage isloaded and there is no need to wait for the resources to be available.
Which statement should be used to call personalizeWebsiteContent based on the above business requirement?
- A . windows,addEventListener(‘load’, personalizeWebsiteContent);
- B . windows,addEventListener(‘DOMContent Loaded ‘, personalizeWebsiteContent);
- C . windows,addEventListener(‘onload’, personalizeWebsiteContent);
- D . windows,addEventListener(‘onDOMCContentLoaded’, personalizeWebsiteContent);
Considering type coercion, what does the following expression evaluate to?
True + ‘13’ + NaN
- A . ‘ 113Nan ’
- B . 14
- C . ‘ true13 ’
- D . ‘ true13NaN ’
Refer to the following array:
Let arr = [1, 2, 3, 4, 5];
Which three options result in x evaluating as [1,2]? Choose 3 answer
- A . let x = arr. slice (2);
- B . let x = arr. slice (0, 2);
- C . let x arr.filter((a) => (return a <= 2 });
- D . let x = arr.filter ((a) => 2 }) ;
- E . let x =arr.splice(0, 2);
Refer to the code below:
Let inArray =[ [ 1, 2 ], [ 3, 4, 5 ] ];
Which two statements result in the array [1, 2, 3, 4, 5]? Choose 2 answers
- A . [ ]. Concat.apply ([ ], inArray);
- B . []. Concat (… inArray);
- C . [ ]. concat.apply(inArray, [ ]);
- D . [ ]. concat ([ ….inArray ] );
Refer to the code below:
Function Person (firstName, lastName, eyecolor) {
this.firstName =firstName;
this.lastName = lastName;
this.eyeColor = eyeColor;
}
Person.job = ‘Developer’;
const myFather = new Person(‘John’, ‘Doe’);
console.log(myFather.job);
What is the output after the code executes?
- A . ReferenceError: eyeColor is not defined
- B . ReferenceError: assignment to undeclared variable “Person”
- C . Developer
- D . Undefined