Practice Free Salesforce Certified JavaScript Developer Exam Online Questions
Refer to code below:
function Person() {
this.firstName = ’John’;
}
Person.prototype ={
Job: x => ‘Developer’
};
const myFather = new Person();
const result=myFather.firstName + ‘ ‘ + myFather.job();
What is the value of the result after line 10 executes?
- A . Error: myFather.job is not a function
- B . Undefined Developer
- C . John undefined
- D . John Developer
is below:
<input type=”file” onchange=”previewFile()”>
<img src=”” height=”200” alt=”Image Preview…”/>
The JavaScript portion is:
01 functionpreviewFile(){
02 const preview = document.querySelector(‘img’);
3 const file = document.querySelector(‘input[type=file]’).files[0];
4 //line 4 code
5 reader.addEventListener(“load”, () => {
6 preview.src = reader.result;
7 },false);
08 //line 8 code
09 }
In lines 04 and 08, which code allows the user to select an image from their local computer, and to display the image in the browser?
- A . 04 const reader = new File();08 if (file) URL.createObjectURL(file);
- B . 04 const reader = new FileReader();08if (file) URL.createObjectURL(file);
- C . 04 const reader = new File();08 if (file) reader.readAsDataURL(file);
- D . 04 const reader = new FileReader();08 if (file) reader.readAsDataURL(file);
A developer wants to use a try…catch statement to catch any error that countSheep () may throw and pass it to a handleError () function.
What is the correct implementation of the try…catch?
A)

B)

C)

D)

- A . Option
- B . Option
- C . Option
- D . Option
A test has a dependency on database. query. During the test, the dependency is replaced with an object called database with the method, Calculator query, that returns an array. The developer does not need to verify how many times the method has been called.
Which two test approaches describe the requirement? Choose 2 answers
- A . White box
- B . Stubbing
- C . Black box
- D . Substitution
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);
Which function should a developer use to repeatedly execute code at a fixed interval?
- A . setIntervel
- B . setTimeout
- C . setPeriod
- D . setInteria
Refer to the code below:
console.log(‘’start);
Promise.resolve(‘Success’) .then(function(value){
console.log(‘Success’);
});
console.log(‘End’);
What is the output after the code executes successfully?
- A . EndStartSuccess
- B . StartSuccessEnd
- C . StartEndSuccess
- D . SuccessStartEnd
Refer to the code below:

Which value can a developer expect when referencing country,capital,cityString?
- A . ‘London’
- B . undefined
- C . An error
- D . ‘NaN’
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.
Const sumFunction = arr => {
Return arr.reduce((result, current) => {
//
Result += current;
//
), 10);
);
Which option makes the code work as expected?
- A . Replace line02 with return arr.map(( result, current) => (
- B . Replace line 04 with result = result +current;
- C . Replace line 03 with if(arr.length == 0 ) (return 0; )
- D . Replace line 05 with return result;

