ExamGecko
Home Home / Salesforce / Certified JavaScript Developer I

Salesforce Certified JavaScript Developer I Practice Test - Questions Answers, Page 10

Question list
Search
Search

List of questions

Search

Related questions











Given the code below: const copy = JSON.stringify([ new String(' false '), new Bollean( false ), undefined ]); What is the value of copy?

A.
-- [ \"false\" , { } ]--
A.
-- [ \"false\" , { } ]--
Answers
B.
-- [ false, { } ]--
B.
-- [ false, { } ]--
Answers
C.
-- [ \"false\" , false, undefined ]--
C.
-- [ \"false\" , false, undefined ]--
Answers
D.
-- [ \"false\" ,false, null ]--
D.
-- [ \"false\" ,false, null ]--
Answers
Suggested answer: D

The developer wants to test the array shown: const arr = Array(5).fill(0) Which two tests are the most accurate for this array ?

Choose 2 answers:

A.
console.assert( arr.length === 5 );
A.
console.assert( arr.length === 5 );
Answers
B.
arr.forEach(elem => console.assert(elem === 0)) ;
B.
arr.forEach(elem => console.assert(elem === 0)) ;
Answers
C.
console.assert(arr[0] === 0 && arr[ arr.length] === 0);
C.
console.assert(arr[0] === 0 && arr[ arr.length] === 0);
Answers
D.
console.assert (arr.length >0);
D.
console.assert (arr.length >0);
Answers
Suggested answer: A, B

A developer receives a comment from the Tech Lead that the code given below has error:

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';
A.
01 let monthName ='July';
Answers
B.
02 let year =2019;
B.
02 let year =2019;
Answers
C.
02 const year = 2020;
C.
02 const year = 2020;
Answers
D.
03 if (year == 2019) {
D.
03 if (year == 2019) {
Answers
Suggested answer: A

Refer to the following code:

<html lang="en">

<body>

<div onclick = "console.log('Outer message') ;">

<button id ="myButton">CLick me<button>

</div>

</body>

<script>

function displayMessage(ev) {

ev.stopPropagation();

console.log('Inner message.');

}

const elem = document.getElementById('myButton');

elem.addEventListener('click' , displayMessage);

</script>

</html> What will the console show when the button is clicked?

A.
Outer message
A.
Outer message
Answers
B.
Outer messageInner message
B.
Outer messageInner message
Answers
C.
Inner messageOuter message
C.
Inner messageOuter message
Answers
D.
Inner message
D.
Inner message
Answers
Suggested answer: D

Refer to the code below: function foo () { const a =2; function bat() { console.log(a);

} return bar;

} Why does the function bar have access to variable a ?

A.
Inner function's scope
A.
Inner function's scope
Answers
B.
Hoisting
B.
Hoisting
Answers
C.
Outer function's scope
C.
Outer function's scope
Answers
D.
Prototype chain
D.
Prototype chain
Answers
Suggested answer: C

Given the following code:

document.body.addEventListener(' click ', (event) => {

if (/* CODE REPLACEMENT HERE */) {

console.log('button clicked!');

)

});

Which replacement for the conditional statement on line 02 allows a developer to correctly determine that a button on page is clicked?

A.
Event.clicked
A.
Event.clicked
Answers
B.
e.nodeTarget ==this
B.
e.nodeTarget ==this
Answers
C.
event.target.nodeName == 'BUTTON'
C.
event.target.nodeName == 'BUTTON'
Answers
D.
button.addEventListener('click')
D.
button.addEventListener('click')
Answers
Suggested answer: C

Given the following code:

document.body.addEventListener(' click ', (event) => {

if (/* CODE REPLACEMENT HERE */) {

console.log('button clicked!');

)

});

Which replacement for the conditional statement on line 02 allows a developer to correctly determine that a button on page is clicked?

A.
Event.clicked
A.
Event.clicked
Answers
B.
e.nodeTarget ==this
B.
e.nodeTarget ==this
Answers
C.
event.target.nodeName == 'BUTTON'
C.
event.target.nodeName == 'BUTTON'
Answers
D.
button.addEventListener('click')
D.
button.addEventListener('click')
Answers
Suggested answer: C

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()
A.
console.timeLog()
Answers
B.
console.getTime()
B.
console.getTime()
Answers
C.
console.trace()
C.
console.trace()
Answers
D.
console.timeStamp()
D.
console.timeStamp()
Answers
Suggested answer: A

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
A.
EndStartSuccess
Answers
B.
StartSuccessEnd
B.
StartSuccessEnd
Answers
C.
StartEndSuccess
C.
StartEndSuccess
Answers
D.
SuccessStartEnd
D.
SuccessStartEnd
Answers
Suggested answer: C

Refer to HTML below:

<div id ="main">

<div id = " card-00">This card is smaller.</div>

<div id = "card-01">The width and height of this card is determined by its contents.</div>

</div> Which expression outputs the screen width of the element with the ID card-01?

A.
document.getElementById(' card-01 ').getBoundingClientRest().width
A.
document.getElementById(' card-01 ').getBoundingClientRest().width
Answers
B.
document.getElementById(' card-01 ').style.width
B.
document.getElementById(' card-01 ').style.width
Answers
C.
document.getElementById(' card-01 ').width
C.
document.getElementById(' card-01 ').width
Answers
D.
document.getElementById(' card-01 ').innerHTML.lenght*e
D.
document.getElementById(' card-01 ').innerHTML.lenght*e
Answers
Suggested answer: A
Total 224 questions
Go to page: of 23