Salesforce Certified JavaScript Developer I

अब Quizwiz के साथ अपने होमवर्क और परीक्षाओं को एस करें!

Which statement can a developer apply to increment the browser's navigation history without a page refresh? A. window.history.pushState(newStateObject, ' ', null); B. window.history.replaceState(newStateObject,' ', null); C. window.history.pushState(newStateObject); D. window.history.state.push(newStateObject);

A Reference: https://gomakethings.com/how-to-update-the-browser-url-without-refreshing-the-page-using-the-vanilla-js-history-api/

A developer is setting up a Node,js server and is creating a script at the root of the source code, index,js, that will start the server when executed. The developer declares a variable that needs the folder location that the code executes from.Which global variable can be used in the script? A. _dirname B. window.location C. _filename D. this.path

A `__dirname` is a global variable in Node.js that represents the directory name of the current module. It provides the absolute path of the directory containing the currently executing script.

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 >0); B. console.assert( arr.length === 5 ); C. console.assert(arr[0] === 0 && arr[ arr.length] === 0); D. arr.forEach(elem => console.assert(elem === 0)) ;

AD

What are two unique features of functions defined with a fat arrow as compared to normal function definition?Choose 2 answers A. If the function has a single expression in the function body, the expression will be evaluated and implicit returned. B. The function receives an argument that is always in scope, called parentThis, which is the enclosing lexical scope. C. The function uses the this from the enclosing scope. D. The function generated its own this making it useful for separating the function's scope from its enclosing scope.

AD

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 but this.name remains undefined. B. Window.name is assigned to 'hello' and the variable z remains undefined. C. Window.m is assigned the correct object. D. The z variable is assigned the correct object.

B

developer uses the code below to format a date. const date= new Date(2020,05,10); const dateDis ={year:'numeric', month:'long',day:'numeric'}; const fdate = date.toLocaleDateString('en',dateDis); console.log(fdate); After executing, what is the value of formattedDate? A. June 10, 2020 B. May 10, 2020 C. November 05, 2020 D. October 05, 2020

A

Refer to the code below:Const resolveAfterMilliseconds = (ms) => Promise.resolve ( setTimeout (( => console.log(ms), ms )); Const aPromise = await resolveAfterMilliseconds(500); Const bPromise = await resolveAfterMilliseconds(500); Await aPromise, await bPromise; What is the result of running line 05? A. aPromise and bPromise run sequentially. B. Neither aPromise or bPromise runs. C. Only aPromise runs. D. aPromise and bPromise run in parallel.

A

Which code statement correctly retrieves and returns an object from localStorage? A. const retrieveFromLocalStorage = (storageKey) =>{return JSON.parse(window.localStorage.getItem(storageKey));} B. const retrieveFromLocalStorage = () =>{return JSON.stringify(window.localStorage.getItem(storageKey));} C. const retrieveFromLocalStorage = (storageKey) =>{return window.localStorage.getItem(storageKey);} D. const retrieveFromLocalStorage = (storageKey) =>{return window.localStorage[storageKey];}

A

A developer has the following array of student test grades: Let arr = [ 7, 8, 5, 8, 9 ]; The Teacher wants to double each score and then see an array of the students who scored more than 15 points.How should the developer implement the request? A. Let arr1 = arr.map((num) => num*2). Filter (( val) => val > 15); B. Let arr1 = arr.map((num) => ( num *2)).filterBy((val) => ( val >15 )); C. Let arr1 = arr.filter(( val) => ( return val > 15 )) .map (( num) => ( return num *2 )) D. Let arr1 = arr.mapBy (( num) => ( return num *2 )) .filterBy (( val ) => return val > 15 )) ;

A

A developer has two ways to write a function: Option A: function Monster() {This.growl = () => {Console.log ("Grr!");}} Option B: function Monster() {}; Monster.prototype.growl =() => {console.log("Grr!");} After deciding on an option, the developer creates 1000 monster objects.How many growl methods are created with Option A Option B? A. 1000 growl method is created for Option A. 1 growl methods are created for Option B. B. 1 growl method is created regardless of which option is used. C. 1 growl method is created for Option A. 1000 growl methods are created for Option B. D. 1000 growl methods are created regardless of which option is used.

A

Given the code below: Setcurrent URL (); console.log('The current URL is: ' +url ); function setCurrentUrl() { Url = window.location.href: What happens when the code executes? A. The url variable has global scope and line 02 executes correctly. B. The url variable has local scope and line 02 executes correctly. C. The url variable has local scope and line 02 throws an error. D. The url variable has global scope and line 02 throws an error.

A

Refer to code below: Const objBook = {Title: 'Javascript',}; Object.preventExtensions(objBook); Const newObjBook = objBook; newObjectBook.author = 'Robert'; What are the values of objBook and newObjBook respectively ? A. [title: "javaScript"] [title: "javaScript"] B. {author: "Robert"}{author: "Robert", title: "javaScript} C. {author: "Robert", title: "javaScript}Undefined D. {author: "Robert", title: "javaScript}{author: "Robert", title: "javaScript}

A

Refer to the code below: Const resolveAfterMilliseconds = (ms) => Promise.resolve ( setTimeout (( => console.log(ms), ms )); Const aPromise = await resolveAfterMilliseconds(500); Const bPromise = await resolveAfterMilliseconds(500); Await aPromise, wait bPromise; What is the result of running line 05? A. aPromise and bPromise run in parallel. B. Only aPromise runs. C. aPromise and bPromise run sequentially. D. Neither aPromise or bPromise runs.

A

Which option is true about the strict mode in imported modules? A. Imported modules are in strict mode whether you declare them as such or not. B. Add the statement use non-strict, before any other statements in the module to enablenot-strict mode. C. You can only reference notStrict() functions from the imported module. D. Add the statement use strict =false; before any other statements in the module to enablenot- strict mode.

A. Source: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/import

Refer to the code declarations below: let str1 = 'Java'; let str2 = 'Script'; Which three expressions return the string JavaScript?Choose 3 answers A. $(str1) $ (str2} '; B. Str1 + str2; C. Str1.concat (str2); D. Concat (str1, str2); E. Str1.join (str2);

ABC

Which three statements are true about promises ?Choose 3 answers A. A fulfilled or rejected promise will not change states . B. A Promise has a .then() method. C. The executor of a new Promise runs automatically. D. A settled promise can become resolved. E. A pending promise can become fulfilled, settled, or rejected.

ABC

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 ') ;)

ABE

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 replace line 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) {

AC

Refer to the code below? Let searchString = ' look for this '; Which two options remove the whitespace from the beginning of searchString?Choose 2 answers A. searchString.trimStart(); B. trimStart(searchString); C. searchString.replace(/*\s\s*/, ''); D. searchString.trimEnd();

AC

GIven a value, which three options can a developer use to detect if the value is NaN?Choose 3 answers ! A. Object.is(value, NaN) B. value == NaN C. Number.isNaN(value) D. value ! == value E. value === Number.NaN

ACD

Refer to the following array: Let arr = [1, 2, 3, 4, 5]; Which three options result in x evaluating as [1, 2]?Choose 3 answer A. let x = arr. slice (0, 2); B. let x = arr. slice (2); C. let x arr.filter((a) => (return a <= 2 }); D. let x = arr.filter ((a) => 2 }) ; E. let x =arr.splice(0, 2);

ACE

A developer wants to use a module called DatePrettyPrint. This module exports one default function called printDate(). How can a developer import and use the printDate() function? A. import printDate() from '/path/DatePrettyPrint.js'; printDate(); B. import printDate from '/path/DatePrettyPrint.js'; printDate(); C. import DatePrettyPrint from '/path/DatePrettyPrint.js'; DatePrettyPrint.printDate(); D. import printDate from '/path/DatePrettyPrint.js'; DatePrettyPrint.printDate();

B

Given the code below: Function myFunction(){ A =5; Var b =1; } myFunction(); console.log(a); console.log(b); What is the expected output? A. Both lines 08 and 09 are executed, but values outputted are undefined. B. Line 08 outputs the variable, but line 09 throws an error. C. Both lines 08 and 09 are executed, and the variables are outputted. D. Line 08 thrones an error, therefore line 09 is never executed.

B

Which option is true about the strict mode in imported modules? A. Add the statement use strict =false; before any other statements in the module to enable not- strict mode. B. Imported modules are in strict mode whether you declare them as such or not. C. Add the statement use non-strict, before any other statements in the module to enable not-strict mode. D. You can only reference notStrict() functions from the imported module.

B

bar.awesome is a popular JavaScript module. the versions publish to npm are: 1.2 1.3.1 1.3.5 1.4.0 Teams at Universal Containers use this module in a number of projects. A particular project has the package, json definition below. { "name" : "UC Project Extra", "version" : "0.0.5", "dependency" : { "bar.awesome" : "~1.3.0" } } A developer runs this command: npm install.Which version of bar .awesome is installed? A. 1.4.0 B. 1.3.5 C. 1.3.1 D. The command fails, because version 1.3.0 is not found

B

Given the expressions var1 and var2, what are two valid ways to return the concatenation of the two expressions and ensure it is string? Choose 2 answers A. var1 + var2 B. var1.toString() + var2.toString() C. String (var1).concat(var2) D. String.concat(var1 +var2)

BC

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 are used to address this ?Choose 2 answers A. Create a new window object in the root file. B. Assign variables to the global object. C. Assign variables to module.exports and require them as needed. D. Use the document object instead of the window object.

BC

Refer to the following code that imports a module named utils: import (foo, bar) from '/path/Utils.js'; foo() ; bar() ; Which two implementations of Utils.js export foo and bar such that the code above runs without error?Choose 2 answers A. // FooUtils.js and BarUtils.js exist Import (foo) from '/path/FooUtils.js'; Import (boo) from ' /path/NarUtils.js'; B. const foo = () => { return 'foo' ; } const bar = () => { return 'bar' ; } export { bar, foo } C. Export default class { foo() { return 'foo' ; } bar() { return 'bar' ; }} D. const foo = () => { return 'foo';} const bar = () => {return 'bar'; } Export default foo, bar;

BC

Refer to the following code: 01 function Tiger(){ 02 this.Type = 'Cat'; 03 this.size = 'large'; 04 } 05 06 let tony = new Tiger(); 07 tony.roar = () =>{ 08 console.log('They\'re great1'); 09 }; 10 11 function Lion(){ 12 this.type = 'Cat'; 13 this.size = 'large'; 14 } 15 16 let leo = new Lion(); 17 //Insert code here 18 leo.roar(); Which two statements could be inserted at line 17 to enable the function call on line 18?Choose 2 answers. A. Leo.prototype.roar = () => { console.log('They\'re pretty good:'); }; B. Object.assign(leo,tony); C. Leo.roar = () => { console.log('They\'re pretty good:'); }; D. Object.assign(leo,Tiger);

BC

Refer to the code below: 01 const exec = (item, delay) =>{ 02 new Promise(resolve => setTimeout( () => resolve(item), delay)), 03 async function runParallel() { 04 Const (result1, result2, result3) = await Promise.all{ 05 [exec ('x', '100') , exec('y', 500), exec('z', '100')] 06 ); 07 return `parallel is done: $(result1) $(result2)$(result3)`;8 }}} Which two statements correctly execute the runParallel () function? Choose 2 answers A . Async runParallel () .then(data); B . runParallel ( ). done(function(data){return data;}); C . runParallel () .then(data); D . runParallel () .then(function(data)return data

BD

Which two options are core Node.js modules?Choose 2 answers A. isotream B. http C. exception D. worker

BD

Universal Containers (UC) notices that its application that allows users to search foraccounts makes a network request each time a key is pressed. This results in too manyrequests for the server to handle.● Address this problem, UC decides to implement a debounce function on string changehandler.What are three key steps to implement this debounce function?Choose 3 answers: A. Ensure that the network request has the property debounce set to true. B. When the search string changes, enqueue the request within a setTimeout. C. If there is an existing setTimeout and the search string change, allow the existingsetTimeout to finish, and do not enqueue a new setTimeout. D. If there is an existing setTimeout and the search string changes, cancel the existingsetTimeout using the persisted timerId and replace it with a new setTimeout. E. Store the timeId of the setTimeout last enqueued by the search string change handle.

BDE

A developer at Universal Containers is creating their new landing page based on HTML, CSS, and JavaScript. To ensure that visitors have a good experience, a script named personalizeWebsiteContent needs to be executed when the webpage is fully loaded (HTML content and all related files), in order to do some custom initializations. Which implementation should be used to call Fe:s:-a;::eHec5;te::.-.ter.: based on the business requirement above? A. Add a listener to the window object to handle the DOMContentLoaded event B. Add a handler to the personalizeWebsiteContent script to handle the load event C. Add a listener to the window object to handle the lead event D. Add a handler to the personalizeWebsiteContent script to handle the DOMContentLoaded event

C

A developer creates a simple webpage with an input field. When a user enters text in the input field and clicks the button, the actual value of the field must be displayed in the console. Here is the HTML file content: <input type =" text" value="Hello" name ="input"> <button type ="button" >Display </button> The developer wrote the javascript code below: Const button = document.querySelector('button'); button.addEvenListener('click', () => ( Const input = document.querySelector('input'); console.log(input.getAttribute('value')); When the user clicks the button, the output is always "Hello". What needs to be done make this code work as expected? A. Replace line 02 with button.addCallback("click", function() { B. Replace line 02 with button.addEventListener("onclick", function() { C. Replace line 04 with console.log(input .value); D. Replace line 03 with const input = document.getElementByName('input');

C

A developer initiates a server with the file server,js and adds dependencies in the source codes package,json that are required to run the server. Which command should the developer run to start the server locally? Options: A. start server,js B. npm start server,js C. npm start D. node start

C

Refer to the code below: Function Person(firstName, lastName, eyecolor) { this.firstName =firstName; this.lastName = lastName; this.eyeColor = eyeColor; } Person.job = 'Developer'; const myFather = new Person('John', 'Doe'); console.log(myFather.job); What is the output after the code executes? A. Developer B. Undefined C. ReferenceError: eyeColor is not defined D. ReferenceError: assignment to undeclared variable "Person"

C

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: <!--This is an ad --> <div class="ad-library-item ad-hidden" onload="myFunction()"> <img src="/ad-library/ad01.gif" /> </div> 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 browser to execute a script that removes all the element containing the class ad-library-item. B. Use the browser console to execute a script that prevents the load event to be fired. C. Use the DOM inspector to remove all the elements containing the class ad-library-item. D. Use the DOM inspector to prevent the load event to be fired.

C

Why would a developer specify a package.jason as a developed forge instead of a dependency ? A. It should be bundled when the package is published. B. Other required packages depend on it for development. C. It is only needed for local development and testing. D. It is required by the application in production.

C

After user acceptance testing, the developer is asked to change the webpage background based on user's location. This change was implemented and deployed for testing.The tester reports that the background is not changing, however it works as required when viewing on the developer's computer.Which two actions will help determine accurate results?Choose 2 answers A. The tester should disable their browser cache. B. The developer should rework the code. C. The tester should dear their browser cache. D. The developer should inspect their browser refresh settings.

CD

Refer to the code below let inArray = [[1,2],[3,4,5]]; which two statements results in the array [1,2,3,4,5]?choose 2 answer A. [ ].concat([...inArray]) B. [ ].concat.apply(inArray,[ ]); C. [ ].concat.apply([ ],inArray); D. [ ].concat(...inArray);

CD

A developer has the function, shown below, that is called when a page loads. function onload() {console.log("Page has loaded!");} Where can the developer see the log statement after loading the page in the browser? A. Browser performance toots B. On the webpage. C. Terminal running the web server. D. Browser javaScript console

D

A developer is setting up a new Node.js server with a client library that is built using events and callbacks.The library:* Will establish a web socket connection and handle receipt of messages to the server* Will be imported with require, and made available with a variable called we.The developer also wants to add error logging if a connection fails.Given this info, which code segment shows the correct way to set up a client with two events that listen at execution time? A. ws.on ('connect', ( ) => { console.log('connected to client'); ws.on('error', (error) => { console.log('ERROR' , error); }); }); B. try{ ws.connect (( ) => { console.log('connected to client'); }); } catch(error) { console.log('ERROR' , error); };} C. ws.connect (( ) => { console.log('connected to client'); }).catch((error) => { console.log('ERROR' , error); }}; D. ws.on ('connect', ( ) => { console.log('connected to client'); }}; ws.on('error', (error) => { console.log('ERROR' , error); }};

D

A developer tries to retrieve all cookies, then sets a certain key value pair in the cookie. These statements are used: 01 document.cookie; 02 document.cookie = 'key = John Smith'; What is the behavior? A. Cookies are read, but the key value is not set because the value is not URL encoded. B. Cookies are not read because line 01 should be document, cookies, but the key value is set and all cookies are wiped. C. Cookies are read and the key value is set, and all cookies are wiped. D. A Cookies are read and the key value is set, the remaining cookies are unaffected.

D

let arr = [1,2,3,4,4,5,4,4]; for(let i=0;i<arr.length;i++){ if(arr[i] ==4){ arr.splice(i,1); i--; } } console.log(arr);

[1,2,3,5]


संबंधित स्टडी सेट्स

9 . 6 THE SHOULDER AND HIP ARE BOTH BALL & SOCKET JOINTS

View Set

Macroeconomics MyEconLab Ch.10.3 Study Plan Quiz

View Set

American history chapter 11 reading check questions

View Set

Fundamentals of Management - Chapter 5 "Planning: The Foundation of Successful Management"

View Set