Download Salesforce Certified JavaScript Developer Study Guide and more Exams Advanced Education in PDF only on Docsity! Salesforce Certified JavaScript Developer (SP22) questions and answers Refer to the code below: Let foodMenu1 = ['pizza', 'burger', 'French fries'];Let finalMenu = foodMenu1; finalMenu.push('Garlic bread'); What is the value of foodMenu1 after the code executes? A [ 'pizza','Burger', 'French fires', 'Garlic bread'] B [ 'pizza','Burger', 'French fires'] C [ 'Garlic bread' , 'pizza','Burger', 'French fires' ] D [ 'Garlic bread'] - CORRECT ANSWER B Which statement accurately describes an aspect of promises? A In a.then() function, returning results is not necessary since callbacks will catch the result of a previous promise. B .then() cannot be added after a catch. C Arguments for the callback function passed to .then() are optional. D .then() manipulates and returns the original promise. - CORRECT ANSWER C A developer is wondering whether to use, Promise, then or Promise.catch, especially when promise throws an error. Which two promises are rejected? A. Promise.reject('cool error here').then(error => console.error(error)); B. New Promise(() => (throw 'cool error here'}).then(null, error => console.error(error))); C. New Promise((resolve, reject) => (throw 'cool error here'}).catch(error => console.error(error)); D. Promise.reject('cool error here').catch(error => console.error(error)); - CORRECT ANSWER CD 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? A window.addEventListener('load',personalizeWebsiteContext); B document.addEventListener(''onDOMContextLoaded', personalizeWebsiteContext); C window.addEventListener('onload', personalizeWebsiteContext); D Document.addEventListener('''DOMContextLoaded' , personalizeWebsiteContext - CORRECT ANSWER A Refer to the code below: Let textValue = '1984'; Which code assignment shows a correct way to convert this string to an integer? A Let numberValue = Integer(textValue); B Let numberValue = textValue.toInteger(); C Let numberValue = (Number)textValue; D Let numberValue = Number(textValue); - CORRECT ANSWER D A developer creates a class that represents a blog post based on the requirement that a Post should have a body author and view count. The Code shown Below: Class Post {// Insert code here This.body =body This.author =author; this.viewCount = viewCount; } } Which statement should be inserted in the placeholder on line 02 to allow for a variable to be set to a new instanceof a Post with the three attributes correctly populated? A. constructor (body, author, viewCount) { B super (body, author, viewCount) { C constructor() { D Function Post (body, author, viewCount) { - CORRECT ANSWER A Refer to HTML below: <p> The current status of an Order: <span id ="status"> In Progress </span> </p>. Which JavaScript statement changes the text 'In Progress' to 'Completed' ? A document.getElementById("status").Value = 'Completed' ; B document.getElementById("#status").innerHTML = 'Completed' ; C document.getElementById("status").innerHTML = 'Completed' ; D document.getElementById(".status").innerHTML = 'Completed' ; - CORRECT ANSWER C A developer wants to leverage a module to print a price in pretty format, and has imported a method as shown below: Import printPrice from '/path/PricePrettyPrint.js'; Based on the code, what must be true about the printPrice function of the PricePrettyPrint module for this import to work ? A. printPrice must be be a named export B printPrice must be an all export C printPrice must be the default export D. printPrice must be a multi - CORRECT ANSWER C 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 parentThis, 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. D The function uses the this from the enclosing scope. - CORRECT ANSWER AC Given the following code: Counter = 0; const logCounter = () => { console.log(counter); );logCounter(); setTimeout(logCOunter, 1100); setInterval(() => { Counter++ logCounter(); }, 1000); What is logged by the first four log statements? A 0 1 2 3 B 0 1 2 2 C 0 1 1 2 D 0 0 1 2 - CORRECT ANSWER C