Labour Day Special - Limited Time 65% Discount Offer - Ends in 0d 00h 00m 00s - Coupon code: top65certs

Full Access Salesforce JavaScript-Developer-I Tutorials

Salesforce Certified JavaScript Developer I (SP23) Questions and Answers

Question 9

A developer is wondering whether to use, Promise.then or Promise.catch, especially

when a Promise throws an error?

Which two promises are rejected?

Which 2 are correct?

Options:

A.

Promise.reject(‘cool error here’).then(error => console.error(error));

B.

Promise.reject(‘cool error here’).catch(error => console.error(error));

C.

New Promise((resolve, reject) => (throw ‘cool error here’}).catch(error =>

console.error(error)) ;

D.

New Promise(() => (throw ‘cool error here’}).then(null, error => console.error(error)));

Question 10

A developer at Universal Containers creates a new landing page based on HTML, CSS, and

JavaScript TO ensure that visitors have a good experience, a script named personaliseContext

needs to be executed when the webpage is fully loaded (HTML content and all related files ), in

order to do some custom initialization.

Which statement should be used to call personalizeWebsiteContent based on the above

business requirement?

Options:

A.

document.addEventListener(‘’onDOMContextLoaded’, personalizeWebsiteContext);

B.

window.addEventListener(‘load’,personalizeWebsiteContext);

C.

window.addEventListener(‘onload’, personalizeWebsiteContext);

D.

Document.addEventListener(‘‘’DOMContextLoaded’ , personalizeWebsiteContext);

Question 11

Given the following code:

What is the output of line 02?

Options:

A.

"null"

B.

"x-

C.

"undefined" 0

D.

'object"

Question 12

A developer implements and calls the following code when an application state change occurs:

Const onStateChange =innerPageState) => {

window.history.pushState(newPageState, ‘ ’, null);

}

If the back button is clicked after this method is executed, what can a developer expect?

Options:

A.

A navigate event is fired with a state property that details the previous application state.

B.

The page is navigated away from and the previous page in the browser’s history is loaded.

C.

The page reloads and all Javascript is reinitialized.

D.

A popstate event is fired with a state property that details the application’s last state.