ExamGecko
Home Home / Salesforce / Certified JavaScript Developer I

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

Question list
Search
Search

List of questions

Search

Related questions











Universal Containers recently launched its new landing page to host a crowd-funding campaign. The page uses an external library to display some third-party ads. Once the page is fully loaded, it creates more than 50 new HTML items placed randomly inside the DOM, like the one in the code below:

All the elements includes the same ad-library-item class, They are hidden by default, and they are randomly displayed while the user navigates through the page.

A.
Use the DOM inspector to prevent the load event to be fired.
A.
Use the DOM inspector to prevent the load event to be fired.
Answers
B.
Use the browser to execute a script that removes all the element containing the class ad-libraryitem.
B.
Use the browser to execute a script that removes all the element containing the class ad-libraryitem.
Answers
C.
Use the DOM inspector to remove all the elements containing the class ad-library-item.
C.
Use the DOM inspector to remove all the elements containing the class ad-library-item.
Answers
D.
Use the browser console to execute a script that prevents the load event to be fired.
D.
Use the browser console to execute a script that prevents the load event to be fired.
Answers
Suggested answer: C

Which code statement correctly retrieves and returns an object from localStorage?

A.
const retrieveFromLocalStorage = () =>{return JSON.stringify(window.localStorage.getItem(storageKey));}
A.
const retrieveFromLocalStorage = () =>{return JSON.stringify(window.localStorage.getItem(storageKey));}
Answers
B.
const retrieveFromLocalStorage = (storageKey) =>{return window.localStorage.getItem(storageKey);}
B.
const retrieveFromLocalStorage = (storageKey) =>{return window.localStorage.getItem(storageKey);}
Answers
C.
const retrieveFromLocalStorage = (storageKey) =>{return JSON.parse(window.localStorage.getItem(storageKey));}
C.
const retrieveFromLocalStorage = (storageKey) =>{return JSON.parse(window.localStorage.getItem(storageKey));}
Answers
D.
const retrieveFromLocalStorage = (storageKey) =>{return window.localStorage[storageKey];}
D.
const retrieveFromLocalStorage = (storageKey) =>{return window.localStorage[storageKey];}
Answers
Suggested answer: C

is below:

<input type="file" onchange="previewFile()">

<img src="" height="200" alt="Image Preview…"/>

The JavaScript portion is:

01 function previewFile(){

02 const preview = document.querySelector('img');

03 const file = document.querySelector('input[type=file]').files[0];

04 //line 4 code

05 reader.addEventListener("load", () => {

06 preview.src = reader.result;

07 },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);
A.
04 const reader = new File();08 if (file) URL.createObjectURL(file);
Answers
B.
04 const reader = new FileReader();08 if (file) URL.createObjectURL(file);
B.
04 const reader = new FileReader();08 if (file) URL.createObjectURL(file);
Answers
C.
04 const reader = new File();08 if (file) reader.readAsDataURL(file);
C.
04 const reader = new File();08 if (file) reader.readAsDataURL(file);
Answers
D.
04 const reader = new FileReader();08 if (file) reader.readAsDataURL(file);
D.
04 const reader = new FileReader();08 if (file) reader.readAsDataURL(file);
Answers
Suggested answer: D

A developer creates a generic function to log custom messages in the console. To do this, the function below is implemented.

01 function logStatus(status){

02 console./*Answer goes here*/{'Item status is: %s', status};

03 }

Which three console logging methods allow the use of string substitution in line 02?

A.
Assert
A.
Assert
Answers
B.
Log
B.
Log
Answers
C.
Message
C.
Message
Answers
D.
Info
D.
Info
Answers
E.
Error
E.
Error
Answers
Suggested answer: B, D, E

A developer wrote the following code:

01 let X = object.value;

02

03 try {

04 handleObjectValue(X);

05 } catch (error) {

06 handleError(error);

07 }

The developer has a getNextValue function to execute after handleObjectValue(), but does not want to execute getNextValue() if an error occurs.

How can the developer change the code to ensure this behavior?

A.
03 try{04 handleObjectValue(x);05 } catch(error){06 handleError(error);07 } then {08 getNextValue();09 }
A.
03 try{04 handleObjectValue(x);05 } catch(error){06 handleError(error);07 } then {08 getNextValue();09 }
Answers
B.
03 try{04 handleObjectValue(x);05 } catch(error){06 handleError(error);07 } finally {08 getNextValue();10 }
B.
03 try{04 handleObjectValue(x);05 } catch(error){06 handleError(error);07 } finally {08 getNextValue();10 }
Answers
C.
03 try{04 handleObjectValue(x);05 } catch(error){06 handleError(error);07 }08 getNextValue();
C.
03 try{04 handleObjectValue(x);05 } catch(error){06 handleError(error);07 }08 getNextValue();
Answers
D.
03 try {04 handleObjectValue(x)05 ……………………
D.
03 try {04 handleObjectValue(x)05 ……………………
Answers
Suggested answer: D

Refer to the code:

Given the code above, which three properties are set pet1?

Choose 3 answers:

A.
Name
A.
Name
Answers
B.
canTalk
B.
canTalk
Answers
C.
Type
C.
Type
Answers
D.
Owner
D.
Owner
Answers
E.
Size
E.
Size
Answers
Suggested answer: B, C, E

Refer to the code below:

Let car1 = new Promise((_ , reject) =>

setTimeout(reject, 2000, "car 1 crashed in" =>

Let car2 =new Promise(resolve => setTimeout(resolve, 1500, "car 2 completed")

Let car3 =new Promise(resolve => setTimeout(resolve, 3000, "car 3 completed")

Promise.race(( car1, car2, car3))

.then (value => (

Let result = '$(value) the race.';)}

.catch(arr => {

console.log("Race is cancelled.", err);

});

What is the value of result when Promise.race executes?

A.
Car 3 completes the race
A.
Car 3 completes the race
Answers
B.
Car 2 completed the race.
B.
Car 2 completed the race.
Answers
C.
Car 1 crashed in the race.
C.
Car 1 crashed in the race.
Answers
D.
Race is cancelled.
D.
Race is cancelled.
Answers
Suggested answer: B

Refer to the following code:

Let sampleText = 'The quick brown fox jumps';

A developer needs to determine if a certain substring is part of a string.

Which three expressions return true for the given substring ?

Choose 3 answers

A.
sampleText.includes('fox');
A.
sampleText.includes('fox');
Answers
B.
sampleText.includes(' quick ', 4);
B.
sampleText.includes(' quick ', 4);
Answers
C.
sampleText.includes(' Fox ', 3)
C.
sampleText.includes(' Fox ', 3)
Answers
D.
sampleText.includes(' fox ');
D.
sampleText.includes(' fox ');
Answers
E.
sampleText.includes(' quick ') !== -1;
E.
sampleText.includes(' quick ') !== -1;
Answers
Suggested answer: B, D, E

Given two expressions var1 and var2. What are two valid ways to return the logical AND of the two expressions and ensure it is data type Boolean ?

Choose 2 answers:

A.
Boolean(var1 && var2)
A.
Boolean(var1 && var2)
Answers
B.
var1 && var2
B.
var1 && var2
Answers
C.
var1.toBoolean() && var2toBoolean()
C.
var1.toBoolean() && var2toBoolean()
Answers
D.
Boolean(var1) && Boolean(var2)
D.
Boolean(var1) && Boolean(var2)
Answers
Suggested answer: A, D

Cloud Kicks has a class to represent items for sale in an online store, as shown below:

Class Item{ constructor (name, price){ this.name = name; this.price = price;

} formattedPrice(){ return 's' + String(this.price);}} A new business requirement comes in that requests a ClothingItem class that should have all of the properties and methods of the Item class but will also have properties that are specific to clothes.

Which line of code properly declares the clothingItem class such that it inherits from Item?

A.
Class ClothingItem implements Item{
A.
Class ClothingItem implements Item{
Answers
B.
Class ClothingItem {
B.
Class ClothingItem {
Answers
C.
Class ClothingItem super Item {
C.
Class ClothingItem super Item {
Answers
D.
Class ClothingItem extends Item {
D.
Class ClothingItem extends Item {
Answers
Suggested answer: D
Total 224 questions
Go to page: of 23