Salesforce Certified JavaScript Developer Exam Practice Questions
Salesforce Certified JavaScript Developer Exam Practice Questions
What's Inside:
Important Note:
For full access to the complete question bank and topic-wise explanations, visit:
CertQuestionsBank.com
FB page: https://www.facebook.com/certquestionsbank
Share some Salesforce Certified JavaScript Developer exam online
questions below.
1.Refer to the code below:
const car = {
price:100,
getPrice:function(){
return this.price;
}
};
const customCar = Object.create(car);
customCar.price = 70;
delete customCar.price;const result = customCar.getPrice(); Whatis the value of result after the code
executes?
A. 100
B. undefined
C. null
D. 70
Answer: A
2.Which three options show valid methods for creating a fat arrow function?
Choose 3 answers
A. x => (console.log(‘ executed ’) ; )
B. [ ] => (console.log(‘ executed ’) ;)
C. () => (console.log(‘ executed ’) ;)
D. X,y,z => (console.log(‘ executed ’) ;)
E. (x,y,z) => (console.log(‘ executed ’) ;)
Answer: A,E
4.Which two code snippets show working examples of a recursive function? Choose 2 answers
A. Let countingDown = function(startNumber) {
If ( startNumber >0) {
console.log(startNumber) ;
return countingDown(startNUmber);
} else {
return startNumber;
}};
B. Function factorial ( numVar ) {
If (numVar < 0) return;
If ( numVar === 0 ) return 1;
return numVar -1;
C. Const sumToTen = numVar => {
If (numVar < 0)
Return;
return sumToTen(numVar + 1)};
D. Const factorial =numVar => {
If (numVar < 0) return;
If ( numVar === 0 ) return 1;
return numVar * factorial ( numVar - 1 );
};
Answer: A,D
Which code should replace the placeholder comment on line 05 to highlight accounts that match the
search string'
A. 'yellow': null
B. null: 'yellow’
C. 'none1: "yellow’
D. 'yellow: 'none'
Answer: D
7.In the browser, the window object is often used to assign variables that require the broadest scope
in an application Node.js application does not have access to the window object by default.
Which two methods areused to address this? Choose 2 answers
A. Use the document object instead of the window object.
B. Assign variables to the global object.
C. Create a new window object in the root file.
D. Assign variables to module.exports and require them as needed.
Answer: B
9.A developer wants to define a function log to be used a few times on a single-file JavaScript script.
01 // Line 1 replacement
02 console.log('"LOG:', logInput);
03 }
Which two options can correctly replaceline 01 and declare the function for use? Choose 2 answers
A. function leg(logInput) {
B. const log(loginInput) {
C. const log = (logInput) => {
D. function log = (logInput) {
Answer: A,C
12.There is a new requirement for a developer to implement a currPrice method that will return the
current price of the item or sales..
15.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
Answer: A
17.A developer has code that calculates a restaurant bill, but generates incorrect answers while
testing the code:
function calculateBill (items) {
let total = 0;
total += findSubTotal(items);
total += addTax(total);
total += addTip(total);
return total;
}
Which option allows the developer to step into each function execution within calculateBill?
A. Using the debugger command on line 05.
B. Using the debugger command on line 03
C. Calling the console.trace (total) method on line 03.
D. Wrapping findSubtotal in a console.log() method.
Answer: A
18.Universal Container (UC) just launched a new landing page, but users complain that the website is
slow. A developer found some functions that cause this problem.
To verify this, the developer decides to do everything and log the time each of these three suspicious
functions consumes.
console.time(‘Performance’);
maybeAHeavyFunction();
thisCouldTakeTooLong();
orMaybeThisOne();
console.endTime(‘Performance’);
Which function can the developer use to obtain the time spent by every one of the three functions?
A. console.timeLog()
B. console.getTime()
C. console.trace()
D. console.timeStamp()
Answer: A
19.A developer receives a comment from the Tech Lead that the code given below has error:
const monthName = ‘July’;
const year = 2019;
if(year === 2019) {
monthName =‘June’;
}
Which line edit should be made to make this code run?
A. 01 let monthName =’July’;
B. 02 let year =2019;
C. 02 const year = 2020;
D. 03 if (year == 2019) {
Answer: A
20.Which statement can a developer apply to increment the browser's navigation history without a
page refresh?
A. window.history.pushState(newStateObject);
B. window.history.pushStare(newStateObject, ' ', null);
C. window.history.replaceState(newStateObject,'', null);
D. window.history.state.push(newStateObject);
Answer: C
21.A developer writes the code below to calculate the factorial of a given number function
sum(number) {return number * sum(number-1);
}
sum (3);
What is the result of executing the code.
A. 0
B. 6
C. Error
D. -Infinity
Answer: C
A. Option A
B. Option B
C. Option C
D. Option D
Answer: A
23.A developer is leading the creation of a new browser application that will serve a single page
application. The team wants to use a new web framework Minimalsit.js. The Lead developer wants to
advocate for a more seasoned web framework that already has a community around it.
Which two frameworks should the lead developer advocate for? Choose 2 answers
A. Vue
B. Angular
C. Koa
D. Express
Answer: B,D
24.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);
Answer: D
27.A developer wants to create an object from a function in the browser using the code below.
What happens due to the lack of the mm keyword on line 02?
A. window.name is assigned to 'hello' and the variable = remains undefined.
B. window.m Is assigned the correct object.
C. The m variable is assigned the correct object but this.name remains undefined.
D. The m variable is assigned the correct object.
Answer: A
29.Whichthree actions can be using the JavaScript browser console? Choose 3 answers:
A. View and change DOM the page.
B. Display a report showing the performance of a page.
C. Run code that is not related to page.
D. view, change, and debug the JavaScript code of the page.
E. View and change security cookies.
Answer: A,C,D
30.then(value => (
07 let result = $(value) the race. `;
08 ))
32.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.
Answer: C
33.What are two unique features of functions defined with a fat arrow as compared to normal function
definition? Choose 2 answers
A. The function generated its own this making it useful for separating the function’s scope from its
enclosing scope.
B. The function receives an argument that is always in scope, called parent This, which is the
enclosing lexical scope.
C. If the function has a single expression in the function body, the expression will be evaluated and
implicit returned.
C. The function uses the this from the enclosing scope.
Answer: A,B