Salesforce.javaScript Developer I.v2022!05!18.q146
Salesforce.javaScript Developer I.v2022!05!18.q146
q146
NEW QUESTION: 1
Refer to the code below:
NEW QUESTION: 2
A developer is wondering whether to use, promise, then or provise, catch especially when a
promise throws an error.
Which two promises are rejected? Choose 2 answers
A. New Promise((resolve, reject) => ( throw 'Cool error here')) .catch (error => console (error ));
B. Promise , reject ('Cool error here ') , catch (error => console ,error (error));
C. New promise (() => (throw 'Cool error here ')) , then ((null, error => console, (error)));
D. Promise, rejected (Cool error here'), then (error => console (error ));
Answer: (SHOW ANSWER)
NEW QUESTION: 3
Refer to the code below:
Which two statements correctly execute the runparallel () function?
Choose 2 answers
A. runParralel () . then (data );
B. runParallel () , then (function ) (date) { } 0;
C. runParallel () , done (function ( data)(return data; }};
D. Async runParalled (). Then (data) :
Answer: (SHOW ANSWER)
NEW QUESTION: 4
Refer to the code below:
NEW QUESTION: 5
A developer wants to iterate through an array of objects and count the objects and count
the objects whose property value, name, starts with the letter N.
Const arrObj = [{"name" : "Zach"} , {"name" : "Kate"},{"name" : "Alise"},{"name" : "Bob"},{"name" :
"Natham"},{"name" : "nathaniel"}
Refer to the code snippet below:
01 arrObj.reduce(( acc, curr) => {
02 //missing line 02
02 //missing line 03
04 ). 0);
Which missing lines 02 and 03 return the correct count?
A. Const sum = curr.name.startsWIth('N') ? 1: 0;
Return curr+ sum
B. Const sum = curr.startsWith('N') ? 1: 0;
Return acc +sum
C. Const sum = curr.startsWIth('N') ? 1: 0;
Return curr+ sum
D. Const sum = curr.name.startsWith('N') ? 1: 0;
Return acc +sum
Answer: (SHOW ANSWER)
NEW QUESTION: 6
Considering the implications of 'use strict' on line 04, which three statements describe the
execution of the code?
Choose 3 answers
A. 'use strict' is hoisted, so it has an effect on all lines.
B. Line 05 throws an error.
C. 'use strict' has an effect only on line 05.
D. 'use strict' has an effect between line 04 and the end of the file.
E. z is equal to 3.14.
Answer: (SHOW ANSWER)
NEW QUESTION: 7
Refer to the code below:
let o = {
get js() {
let city1 = String("st. Louis");
let city2 = String(" New York");
return {
firstCity: city1.toLowerCase(),
secondCity: city2.toLowerCase(),
}
}
}
What value can a developer expect when referencing o.js.secondCity?
A. Undefined
B. An error
C. ' New York '
D. ' new york '
Answer: (SHOW ANSWER)
NEW QUESTION: 8
Refer to the code below:
NEW QUESTION: 9
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 to make this code work as expected?
A. Replace line 02 with button.addEventListener("onclick", function() {
B. Replace line 04 with console.log(input .value);
C. Replace line 02 with button.addCallback("click", function() {
D. Replace line 03 with const input = document.getElementByName('input');
Answer: (SHOW ANSWER)
NEW QUESTION: 10
A. [1, 2, 3, 4, 5, 4, 4]
B. [1, 2, 3, 4, 4, 5, 4]
C. [1, 2, 3, 5]
D. [1, 2, 3, 4, 5, 4]
Answer: (SHOW ANSWER)
NEW QUESTION: 11
A developer wants to create an object from a function in the browser using the code below.
What happens due to lack of the new keyword on line 02?
A. Window. n is assigned the correct object.
B. The a variable is assigned the correct object.
C. Window. === name is assigned to ''hello'' and the variable a n remain undefined.
D. The n variable is assigned the correct object but this- remains undefined.
Answer: (SHOW ANSWER)
NEW QUESTION: 12
Refer to the following code:
Which two statements could be inserted at line 17 to enable the function call on line 18?
Choose 2 answers
A. 1eo.prototype.roar = ( ) => ( console.log (They\'re pretty good1'); );
B. 1eo.roar = () => 9 (console.log('They\'re pretty good1'); 1;
C. Object.assign, assign( 1eo, trigger);
D. Object,assign(1eo, tony) ;
Answer: (SHOW ANSWER)
NEW QUESTION: 13
Why would a developer specify a package as the package.json as a deDepdelivery instead of a
depdelivery?
A. Other required packages depended on it for development.
B. It should be bundled when the package is published.
C. It is required by the application in production.
D. It is only needed for local development and testing.
Answer: (SHOW ANSWER)
NEW QUESTION: 14
Refer to the code below:
01 let car1 = new promise((_, reject) =>
02 setTimeout(reject, 2000, "Car 1 crashed in"));
03 let car2 = new Promise(resolve => setTimeout(resolve, 1500, "Car 2
completed"));
04 let car3 = new Promise(resolve => setTimeout (resolve, 3000, "Car 3
Completed"));
05 Promise.race([car1, car2, car3])
06 .then(value => (
07 let result = $(value) the race. `;
08 ))
09 .catch( arr => (
10 console.log("Race is cancelled.", err);
11 ));
What is the value of result when Promise.race executes?
A. Car 1 crashed in the race.
B. Race is cancelled.
C. Car 3 completed the race.
D. Car 2 completed the race.
Answer: (SHOW ANSWER)
NEW QUESTION: 15
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.trace()
B. console.timeStamp()
C. console.getTime()
D. console.timeLog()
Answer: (SHOW ANSWER)
NEW QUESTION: 16
Given the following code:
NEW QUESTION: 17
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. Function Post (body, author, viewCount) {
B. constructor() {
C. constructor (body, author, viewCount) {
D. super (body, author, viewCount) {
Answer: (SHOW ANSWER)
NEW QUESTION: 18
Refer to the code below:
Async funct on functionUnderTest(isOK) {
If (isOK) return 'OK' ;
Throw new Error('not OK');
)
Which assertion accuretely tests the above code?
A. Console.assert (await functionUnderTest(true), ' not OK ')
B. Console.assert (await functionUnderTest(true), 'OK')
C. Console.assert (await functionUnderTest(true), ' OK ')
D. Console.assert (await functionUnderTest(true), ' not OK ')
Answer: (SHOW ANSWER)
NEW QUESTION: 19
developer removes the HTML class attribute from the checkout button, so now it is
simply:
<button>Checkout</button>.
There is a test to verify the existence of the checkout button, however it looks for a button with
class= "blue". The test fails because no such button is found.
Which type of test category describes this test?
A. False positive
B. True positive
C. True negative
D. False negative
Answer: D (LEAVE A REPLY)
NEW QUESTION: 20
A. window.history.pushStare(newStateObject, ' ', null);
B. window.history.replaceState(newStateObject,' ', null);
C. window.history.pushState(newStateObject);
D. window.history.state.push(newStateObject);
Answer: (SHOW ANSWER)
NEW QUESTION: 21
Refer to the code below:
NEW QUESTION: 22
Refer to the following code:
NEW QUESTION: 23
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)) ;
Answer: (SHOW ANSWER)
NEW QUESTION: 24
Refer to the code below:
A developer needs to dispatch a custom event called update to send information about recordId.
Which two options could a developer insert at the placeholder in line 02 to achieve this? Choose
2 answers
A. 'update' , '123abc'
B. {type ; update ', recordId : '123abc')
C. 'update', {
Detail ; {
recordId, '123abc
)
)
D. 'update', ( recordId ; 123abc'
)
Answer: (SHOW ANSWER)
NEW QUESTION: 25
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 04 with console.log(input .value);
C. Replace line 02 with button.addEventListener("onclick", function() {
D. Replace line 03 with const input = document.getElementByName('input');
Answer: (SHOW ANSWER)
NEW QUESTION: 26
Which option is a core Node;js module?
A. locale
B. Path
C. Ios
D. Memory
Answer: (SHOW ANSWER)
NEW QUESTION: 27
Given the requirement to refactor the code above to JavaScript class format, which class
definition is correct?
A)
B)
C)
D)
A. Option B
B. Option D
C. Option C
D. Option A
Answer: (SHOW ANSWER)
NEW QUESTION: 28
Which two console logs output NaN?
Choose 2 answers | |
A. console.log(parseInt ' ("two')) ;
B. console.log(10 / Number('5) ) ;
C. console.log(10 / 0);
D. console.loeg(10 / 'five');
Answer: (SHOW ANSWER)
NEW QUESTION: 29
Given the requirement to refactor the code above to JavaScript class format, which class
definition is correct?
A)
B)
C)
D)
A. Option B
B. Option D
C. Option C
D. Option A
Answer: (SHOW ANSWER)
NEW QUESTION: 30
NEW QUESTION: 31
What are two unique feature of function defined with a fat arror as compared to normal functional
definition?
Choose 2 answers
A. The function uses the this from the enclosing scope.
B. The function receives an argument that is always in scope, called parent this, which is the
enclosing lexical scope
C. If the function has a single expression in the function body, the expression will be evaluated
and implicitly returned.
D. The function generation its own this making it useful for separating the function's scope its
enclosing scope
Answer: (SHOW ANSWER)
NEW QUESTION: 32
Given the code below.
NEW QUESTION: 33
At Universal Containers, every team has its own way of copying JavaScript objects. The code
Snippet shows an implementation from one team:
Function Person() {
this.firstName = "John";
this.lastName = 'Doe';
This.name =() => (
console.log('Hello $(this.firstName) $(this.firstName)');
)}
Const john = new Person ();
Const dan = JSON.parse(JSON.stringify(john));
dan.firstName ='Dan';
dan.name();
What is the Output of the code execution?
A. Hello John DOe
B. Hello Dan Doe
C. TypeError: dan.name is not a function
D. TypeError: Assignment to constant variable.
Answer: (SHOW ANSWER)
NEW QUESTION: 34
A developer wants to set up a secure web server with Node.js. The developer creates a
directory locally called app-server, and the first file is app-server/index.js
Without using any third-party libraries, what should the developer add to index.js to create the
secure web server?
A. const https =require('https');
B. const server =require('secure-server');
C. const tls = require('tls');
D. const http =require('http');
Answer: A (LEAVE A REPLY)
NEW QUESTION: 35
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. 1000 growl methods are created regardless of which option is used.
D. 1 growl method is created for Option A. 1000 growl methods are created for Option B.
Answer: (SHOW ANSWER)
NEW QUESTION: 36
A developer is required to write a function that calculates the sum of elements in an
array but is getting undefined every time the code is executed. The developer needs to find
what is missing in the code below.
Const sumFunction = arr => {
Return arr.reduce((result, current) => {
//
Result += current;
//
), 10);
);
Which option makes the code work as expected?
A. Replace line 05 with return result;
B. Replace line 03 with if(arr.length == 0 ) ( return 0; )
C. Replace line 04 with result = result +current;
D. Replace line 02 with return arr.map(( result, current) => (
Answer: (SHOW ANSWER)
NEW QUESTION: 37
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 2 completed the race.
B. Car 1 crashed in the race.
C. Car 3 completes the race
D. Race is cancelled.
Answer: (SHOW ANSWER)
NEW QUESTION: 38
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 a multi exportc
B. printPrice must be an all export
C. printPrice must be the default export
D. printPrice must be be a named export
Answer: (SHOW ANSWER)
NEW QUESTION: 39
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. e.nodeTarget ==this
B. button.addEventListener('click')
C. Event.clicked
D. event.target.nodeName == 'BUTTON'
Answer: (SHOW ANSWER)
NEW QUESTION: 40
A developer is trying to handle an error within a function.
Which code segment shows the correct approach to handle an error without propagating it
elsewhere?
A)
B)
C)
D)
A. Option B
B. Option A
C. Option C
D. Option D
Answer: (SHOW ANSWER)
NEW QUESTION: 41
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. const log = (logInput) => {
B. function log = (logInput) {
C. function leg(logInput) {
D. const log(loginInput) {
Answer: (SHOW ANSWER)
NEW QUESTION: 42
A developer creates an object where its properties should be immutable and prevent properties
from being added or modified.
Which method should be used to execute this business requirement?
A. Object. filebase ( )
B. Object. Lock ( )
C. Object. real ( )
D. Object const ( )
Answer: A (LEAVE A REPLY)
NEW QUESTION: 43
A developer has code that calculates a restaurant bill, but generates incorrect answers while
testing the code:
function calculateBill ( items ) {
let total = 0;
total += findSubTotal(items);
total += addTax(total);
total += addTip(total);
return total;
}
Which option allows the developer to step into each function execution within calculateBill?
A. Using the debugger command on line 05.
B. Using the debugger command on line 03
C. Wrapping findSubtotal in a console.log() method.
D. Calling the console.trace (total) method on line 03.
Answer: (SHOW ANSWER)
NEW QUESTION: 44
Refer to the code below:
Const myFunction = arr => {
Return arr.reduce((result, current) =>{
Return result = current;
}, 10};
}
What is the output of this function when called with an empty array ?
A. Throws an error
B. Returns 0
C. Returns 10
D. Returns NaN
Answer: (SHOW ANSWER)
NEW QUESTION: 45
Refer to the code below:
What value can a developer expect when referencing o,js,secondCity?
A. 'new york'
B. 'New York
C. Undefined
D. An error
Answer: (SHOW ANSWER)
NEW QUESTION: 46
Refer to the code below:
NEW QUESTION: 47
A developer needs to debug a Node.js web server because a runtime error keeps occurring at
one of the endpoints.
The developer wants to test the endpoint on a local machine and make the request against a
local server to look at the behavior. In the source code, the server, js file will start the server. the
developer wants to debug the Node.js server only using the terminal.
Which command can the developer use to open the CLI debugger in their current terminal
window?
A. node start inspect server,js
B. node inspect server,js
C. node -i server.js
D. node server,js inspect
Answer: (SHOW ANSWER)
NEW QUESTION: 48
Refer to the following code block:
NEW QUESTION: 49
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.connect (( ) => {
console.log('connected to client'); }).catch((error) => { console.log('ERROR' , error); }};
B. ws.on ('connect', ( ) => {
console.log('connected to client'); ws.on('error', (error) => { console.log('ERROR' , error); });
});
C. ws.on ('connect', ( ) => { console.log('connected to client'); }}; ws.on('error', (error) =>
{ console.log('ERROR' , error); }};
D. try{
ws.connect (( ) => {
console.log('connected to client'); });
Answer: (SHOW ANSWER)
} catch(error) { console.log('ERROR' , error); };
}
NEW QUESTION: 50
Refer to the code below:
NEW QUESTION: 51
A developer has an ErrorMandler module that contains multiple functions.
What kind of export should be leveraged so that multiple function can be used?
A. Multi
B. All
C. default
D. Named
Answer: (SHOW ANSWER)
NEW QUESTION: 52
Refer to the code below:
NEW QUESTION: 53
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 FileReader();
08 if (file) URL.createObjectURL(file);
B. 04 const reader = new File();
08 if (file) reader.readAsDataURL(file);
C. 04 const reader = new File();
08 if (file) URL.createObjectURL(file);
D. 04 const reader = new FileReader();
08 if (file) reader.readAsDataURL(file);
Answer: (SHOW ANSWER)
NEW QUESTION: 54
A developer creates a class that represents a blog post based on the requirements that a Post
should have a body, author, and view count. The code is shown below:
Which statement should be inserted in the placeholder on line 02 to allow for a variable to be sent
to a new instance of a port with the three attributes correctly populated?
A. Constructor ( ) (
B. Function Post (body, author, viewCount) (
C. Constructor (body, author, viewCount) (
D. Super (body, author, viewCount) (
Answer: (SHOW ANSWER)
NEW QUESTION: 55
Refer to the following code:
NEW QUESTION: 56
Refer to code below:
Function muFunction(reassign){
Let x = 1;
var y = 1;
if( reassign ) {
Let x= 2;
Var y = 2;
console.log(x);
console.log(y);}
console.log(x);
console.log(y);}
What is displayed when myFunction(true) is called?
A. 2 2 2 2
B. 2 2 1 1
C. 2 2 undefined undefined
D. 2 2 1 2
Answer: (SHOW ANSWER)
NEW QUESTION: 57
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
B. Hoisting
C. Outer function's scope
D. Prototype chain
Answer: (SHOW ANSWER)
NEW QUESTION: 58
Refer to the code below:
NEW QUESTION: 59
A developer wants to use a try...catch statement to catch any error that countSheep () may throw
and pass it to a handleError () function.
What is the correct implementation of the try...catch?
A)
B)
C)
D)
A. Option
B. Option
C. Option
D. Option
Answer: (SHOW ANSWER)
NEW QUESTION: 60
Given the code below:
Which method can be used to provide a visual representation of the list of users and to allow
sorting by the name or email attribute?
A. console.group(usersList) ;
B. console.table(usersList) ;
C. console.groupCol lapsed (usersList) ;
D. console.info(usersList) ;
Answer: (SHOW ANSWER)
NEW QUESTION: 61
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)`;
08 }
}
}
Which two statements correctly execute the runParallel () function?
Choose 2 answers
A. runParallel () .then(data);
B. Async runParallel () .then(data);
C. runParallel () .then(function(data)
return data
D. runParallel ( ). done(function(data){
return data;
});
Answer: C,D (LEAVE A REPLY)
Valid JavaScript-Developer-I Dumps shared by ExamDiscuss.com for Helping Passing
JavaScript-Developer-I Exam! ExamDiscuss.com now offer the newest JavaScript-
Developer-I exam dumps, the ExamDiscuss.com JavaScript-Developer-I exam questions
have been updated and answers have been corrected get the newest ExamDiscuss.com
JavaScript-Developer-I dumps with Test Engine here:
https://www.examdiscuss.com/Salesforce/exam/JavaScript-Developer-I/premium/ (224 Q&As
Dumps, 35%OFF Special Discount Code: freecram)
NEW QUESTION: 62
Given the following code:
NEW QUESTION: 63
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. Start
End
Success
B. End
Start
Success
C. Success
Start
End
D. Start
Success
End
Answer: (SHOW ANSWER)
NEW QUESTION: 64
Refer to the 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''), innerHTML = 'Completed' ;
B. Document, getElementById (status'') , value = completed' ;
C. Document, getElementById (''status''), innerHTML = 'Completed' ;
D. Document, getElementById (''# status''), innerHTML = 'Completed' ;
Answer: (SHOW ANSWER)
NEW QUESTION: 65
A developer is working on an ecommerce website where the delivery date is dynamically
calculated based on the current day. The code line below is responsible for this calculation.
Const deliveryDate = new Date ();
Due to changes in the business requirements, the delivery date must now be today's date + 9
days.
Which code meets this new requirement?
A. deliveryDate.setDate( Date.current () + 9);
B. deliveryDate.setDate(( new Date ( )).getDate () +9);
C. deliveryDate.date = Date.current () + 9;
D. deliveryDate.date = new Date(+9) ;
Answer: (SHOW ANSWER)
NEW QUESTION: 66
Refer to the code below:
Async funct on functionUnderTest(isOK) {
If (isOK) return 'OK' ;
Throw new Error('not OK');
)
Which assertion accurately tests the above code?
A. Console.assert (await functionUnderTest(true), ' not OK ')
B. Console.assert (await functionUnderTest(true), ' not OK ')
C. Console.assert (await functionUnderTest(true), ' OK ')
D. Console.assert (await functionUnderTest(true), 'OK')
Answer: (SHOW ANSWER)
NEW QUESTION: 67
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. string.concat (var1 +var2)
B. String (var1) .concat (var2)
C. var1.toString ( ) var2.toString ( )
D. var1 + var2
Answer: (SHOW ANSWER)
NEW QUESTION: 68
What is the result of the code block?
A. The console logs only 'flag'.
B. The console logs 'flag' and another flag.
C. The console logs 'flag' and then an error is thrown.
D. An error is thrown.
Answer: (SHOW ANSWER)
NEW QUESTION: 69
developer wants to use a module named universalContainersLib and them call functions from it.
How should a developer import every function from the module and then call the fuctions foo and
bar ?
A. import * ad lib from '/path/universalContainersLib.js';
lib.foo();
lib.bar();
B. import * from '/path/universalContaineraLib.js';
universalContainersLib.foo();
universalContainersLib.bar();
C. import (foo, bar) from '/path/universalContainersLib.js';
foo();
bar();
D. import all from '/path/universalContaineraLib.js';
universalContainersLib.foo();
universalContainersLib.bar();
Answer: (SHOW ANSWER)
NEW QUESTION: 70
A. Ensure that the network request has the property debounce set to true.
B. Store the timeId of the setTimeout last enqueued by the search string change handle.
C. If there is an existing setTimeout and the search string change, allow the existing setTimeout
to finish, and do not enqueue a new setTimeout.
D. If there is an existing setTimeout and the search string changes, cancel the existing
setTimeout using the persisted timerId and replace it with a new setTimeout.
E. When the search string changes, enqueue the request within a setTimeout.
Answer: (SHOW ANSWER)
NEW QUESTION: 71
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 ........................
B. 03 try{
04 handleObjectValue(x);
05 } catch(error){
06 handleError(error);
07 } finally {
08 getNextValue();
10 }
C. 03 try{
04 handleObjectValue(x);
05 } catch(error){
06 handleError(error);
07 } then {
08 getNextValue();
09 }
D. 03 try{
04 handleObjectValue(x);
05 } catch(error){
06 handleError(error);
07 }
08 getNextValue();
Answer: (SHOW ANSWER)
NEW QUESTION: 72
A developer implements a function that adds a few values.
Which three options can the developer invoke for this function to get a return vale of 10? Choose
3 answers
A. Sum (5) (5)
B. Sum (10) ()
C. Sum () (10)
D. Sum (5, 5) ()
E. Sum () (5, 5)
Answer: (SHOW ANSWER)
NEW QUESTION: 73
A developer creates a generic function to log custom messages In the console. To do this, the
function below is implemented.
Which three console logging methods allow the use of string substitution in line 02?
Choose 3 answers
A. error
B. Info
C. Message
D. Assert
E. Log
Answer: (SHOW ANSWER)
NEW QUESTION: 74
A developer has a formatName function that takes two arguments, firstName and lastName and
returns a string. They want to schedule the function to run once after five seconds.
What is the correct syntax to schedule this function?
A. setTimeout ('formatName', 5000, 'John", "Doe');
B. setTimeout (formatName(), 5000, "John", "BDoe");
C. setTimout(() => { formatName("John', 'Doe') }, 5000);
D. setTimeout (formatName('John', ''Doe'), 5000);
Answer: (SHOW ANSWER)
NEW QUESTION: 75
Refer to the following code that imports a module named Utills,
Which two implementations of Utill, je export foo and bar such that the code above runs without
error?
Choose 2 answers
A. Const foo = ( ) => ( return 'foo; ; )
Const bar => => { return 'bar ';}
Export default foo, bar;
B. //FooUtill.js and barUtils, js exist
Import (foo) from ,/Path/footUtils.js,:
Export (foo, bar)
C. Const foo = () => ( return 'foo ' ; )
Const bar => ( return 'bar' ; )
Export (foo, bar)
D. Export default class (
Foo ( ) ( return 'foo ,; )
Bar ( ) ( return ;bar ; )
Answer: D (LEAVE A REPLY)
NEW QUESTION: 76
Which statement can a developer apply to increment the browser's navigation history without a
page refesh?
A. Window.history,state,push.(newStateObject, ' ' null;
B. Window.history,state,push.(newStateObject);
C. Window.history,pushState.(newStateObject, ' ', null)) ;
D. Window.history,pushState.(newStateObject);
Answer: (SHOW ANSWER)
A.
B.
C.
D.
Answer: (SHOW ANSWER)
NEW QUESTION: 78
A developer uses a parsed JSON string to work with user information as in the block below:
01 const userInformation ={
02 " id " : "user-01",
03 "email" : "[email protected]",
04 "age" : 25
Which two options access the email attribute in the object?
Choose 2 answers
A. userInformation(email)
B. userInformation("email")
C. userInformation.get("email")
D. userInformation.email
Answer: B,D (LEAVE A REPLY)
NEW QUESTION: 79
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. Info
B. Assert
C. Log
D. Error
E. Message
Answer: (SHOW ANSWER)
NEW QUESTION: 80
A developer has code that calculates a restaurant bill, but generates incorrect answers while
testing the code.
Which option allows the developer to step into each function execution within calculateBill?
A. Using the debugger command on line 05.
B. Wrapping findsubtotal in a console .log method.
C. Using the debugger command on line 03.
D. Calling the console. Trace( total ) method on line 03.
Answer: (SHOW ANSWER)
NEW QUESTION: 81
A developer wrote a fizzbuzz function that when passed in a number, returns the following:
* 'Fizz' if the number is divisible by 3.
* 'Buzz' if the number is divisible by 5.
* 'Fizzbuzz' if the number is divisible by both 3 and 5.
* Empty string if the number is divisible by neither 3 or 5.
Which two test cases will properly test scenarios for the fizzbuzz function?
Choose 2 answers
A. let res = fizzbuzz(15);
console.assert ( res === ' fizzbuzz ' )
B. let res = fizzbuzz(3);
console.assert ( res === ' buzz ' )
C. let res = fizzbuzz(Infinity);
console.assert ( res === ' ' )
D. let res = fizzbuzz(5);
console.assert ( res === ' ' );
Answer: (SHOW ANSWER)
NEW QUESTION: 82
A developer is asked to fix some bugs reported by users. To do that, the developer adds a
breakpoint for debugging.
Function Car (maxSpeed, color){
This.maxspeed =masSpeed;
This.color = color;
Let carSpeed = document.getElementById(' CarSpeed');
Debugger;
Let fourWheels =new Car (carSpeed.value, 'red');
When the code execution stops at the breakpoint on line 06, which two types of information are
available in the browser console ?
Choose 2 answers:
A. The values of the carSpeed and fourWheels variables
B. A variable displaying the number of instances created for the Car Object.
C. The style, event listeners and other attributes applied to the carSpeed DOM element
D. The information stored in the window.localStorage property
Answer: (SHOW ANSWER)
NEW QUESTION: 83
Refer to the following array:
Let arr1 = [1, 2, 3, 4, 5];
Which two lines of codes result in a second array, arr2, being created such that arr2 is not a
reference to arr1? Choose 2 answers
A. Let arr2 = arr1;
B. Let arr2 = arr1 sort ();
C. Let arr2 = Array. From (arr1) ;
D. Let arr2 = arr1 .slice (0, 5);
Answer: (SHOW ANSWER)
NEW QUESTION: 84
Refer to the code below:
A developer uses a client that makes a GET request that uses a promise to handle the request,
getRequest returns a promise.
Which code modification can the developer make to gracefully handle an error?
A)
B)
C)
D)
A. Option B
B. Option C
C. Option D
D. Option A
Answer: (SHOW ANSWER)
NEW QUESTION: 85
Refer to the code below:
let sayHello = () => {
console.log ('Hello, world!');
};
Which code executes sayHello once, two minutes from now?
A. delay(sayHello, 12000);
B. setTimeout(sayHello, 12000);
C. setTimeout(sayHello(), 12000);
D. setInterval(sayHello, 12000);
Answer: (SHOW ANSWER)
NEW QUESTION: 86
Refer to the code below:
Let str = 'javascript';
Str[0] = 'J';
Str[4] = 'S';
After changing the string index values, the value of str is 'javascript'. What is the reason for this
value:
A. Primitive values are immutable.
B. Non-primitive values are mutable.
C. Primitive values are mutable.
D. Non-primitive values are immutable.
Answer: (SHOW ANSWER)
NEW QUESTION: 87
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. It is only needed for local development and testing.
C. It is required by the application in production.
D. Other required packages depend on it for development.
Answer: B (LEAVE A REPLY)
NEW QUESTION: 88
A developer wants to use a module named universalContainerLib and then call functions from it.
How should a developer import every function from the module and then call the functions foo
and bar?
A. import + from '/path/universalContainerLib.js''
universalContainersLib.foo( ) ;
universalContainersLib bar ( ) :
B. import - as lib from '/path/universalContainerLib.js''
lib.foo( ) ;
lib. bar ( ) ;
C. import (foo,bar) from '/path/universalContainerLib.js''
foo ( ) ;
bar ( ) ;
D. import all from '/path/universalContainerLib.js''
universalContainersLib.foo( ) ;
universalContainersLib bar ( ) :
Answer: (SHOW ANSWER)
NEW QUESTION: 89
A developer has two ways to write a function:
NEW QUESTION: 90
A. Document.addEventListener('''DOMContextLoaded' , personalizeWebsiteContext);
B. window.addEventListener('onload', personalizeWebsiteContext);
C. document.addEventListener(''onDOMContextLoaded', personalizeWebsiteContext);
D. window.addEventListener('load',personalizeWebsiteContext);
Answer: (SHOW ANSWER)
NEW QUESTION: 91
Refer to the following code:
Which statement should be added to line 09 for the code to display. The truck 123AB has a
weight of 5000 Ib. '?
A. This .plate = plate;
B. Vehicle.plate = plate
C. Super.plate = plate;
D. Super = (plate ) ;
Answer: A,B,D (LEAVE A REPLY)
NEW QUESTION: 92
Refer to the following array:
Let arr1 = [ 1, 2, 3, 4, 5 ];
Which two lines of code result in a second array, arr2 being created such that arr2 is not a
reference to arr1?
A. Let arr2 = arr1;
B. Let arr2 = arr1.sort();
C. Let arr2 = Array.from(arr1);
D. Let arr2 = arr1.slice(0, 5);
Answer: (SHOW ANSWER)
NEW QUESTION: 93
Which statement accurately describes an aspect of promises?
A. .then ( ) manipulates and returns the original promise.
B. Agruments for the callback function passed to .then ( ) are optional.
C. In a , them ( ) function, returning results is not necessary since callback will catch the result of
a previous promise.
D. .Them ( ) cannot be added after a catch.
Answer: (SHOW ANSWER)
NEW QUESTION: 94
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;
Answer: (SHOW ANSWER)
NEW QUESTION: 95
Refer to code below:
function Person() {
this.firstName = 'John';
}
Person.prototype ={
Job: x => 'Developer'
};
const myFather = new Person();
const result =myFather.firstName + ' ' + myFather.job();
What is the value of the result after line 10 executes?
A. Undefined Developer
B. John undefined
C. John Developer
D. Error: myFather.job is not a function
Answer: (SHOW ANSWER)
NEW QUESTION: 96
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
B. Race is cancelled.
C. Car 2 completed the race.
D. Car 1 crashed in the race.
Answer: (SHOW ANSWER)
NEW QUESTION: 97
Which three browser specific APIs are available for developer to persist data between page
loads?
Choose 3 answers
A. localStorage
B. cookies
C. IIFEs
D. global variables
E. indexedDB
Answer: (SHOW ANSWER)
NEW QUESTION: 98
The developer wants to test this code:
Const toNumber =(strOrNum) => strOrNum;
Which two tests are most accurate for this code?
Choose 2 answers
A. console.assert(toNumber('-3') < 0);
B. console.assert(Number.isNaN(toNumber()));
C. console.assert(toNumber('2') === 2);
D. console.assert(toNumber () === NaN);
Answer: (SHOW ANSWER)
NEW QUESTION: 99
A developer receives a comment from the Tech lead that the code below gives an error.
A developer writes this code to return a message to a user attempting to register a new
username. If the username is available, a variable named msg is declared and assigned a value
on line 03.
What is the return of msg when getivelibilityMessage ('' bewUserName') is executed and
getAvailability (''newUserName'') returns false?
A. ''Username available''
B. ''msg is not defined''
C. undefined
D. ''newUsername''
Answer: (SHOW ANSWER)
A. undefined
B. ReferenceError: eyeColor is not defined
C. Developer
D. ReferenceError: assignment to undeclared variable ''Person''
Answer: (SHOW ANSWER)
If the back button is clicked after this method is executed, what can a developer expect?
A. The page reloads and all JavaScript is reinitialized.
B. A navigate event is fired with a state properly that details previous application state.
C. The page is navigated away from and previous page in the browser's history is loaded.
D. A popstate event is fired with a state properly that details the application's last state.
Answer: (SHOW ANSWER)
B)
C)
D)
A. Option B
B. Option C
C. Option A
D. Option D
Answer: (SHOW ANSWER)
B)
C)
D)
A. Option C
B. Option A
C. Option B
D. Option D
Answer: (SHOW ANSWER)
A. In a.then() function, returning results is not necessary since callbacks will catch the result of a
previous promise.
B. .then() manipulates and returns the original promise.
C. Arguments for the callback function passed to .then() are optional.
D. .then() cannot be added after a catch.
Answer: (SHOW ANSWER)
A developer import a library that creates a web server. the imported library uses events and
callback to start the server.
Which code should be inserted at line 03 to set up an event and start the web server?
A. Server. on ('connet' , (port) => (
Console.log (Listening on' port);
}};
B. Server .start();
C. server ( (port) => (
Console.log ('Listening on' , port) ;
}};
D. server( );
Answer: (SHOW ANSWER)
Which statement adds the priority-account CSS class to the Unversal Containers row?
A. Document. queryselector ('# row-uc') ,classes. Push (' priority-account');
B. Document. querySelector ( 'row-uc') . classList. Add ( 'pariority-account') ;
C. Document. getElementById ( 'row-uc') addClass ( ' priority-account');
D. Document. querySelectorAll ( '# row-uc ') .classList. add ('priority-account');
Answer: (SHOW ANSWER)
After changing the string index values, the of atr is Javascript''. What is the reason for this value?
A. Primitive values are mutable.
B. Non-primitive values are immutable.
C. Primitive values are immutable
D. Non-primitive values are mutable.
Answer: (SHOW ANSWER)
NEW QUESTION: 141
Refer to the following code:
Which two assert statements are valid tests for this function?
A. Console.assert(sum3((1, '2' ]) 12 );
B. Console.assert(sum3 ([-3, 2]) -1) ;
C. Console.assert(sum3([0]) 0) ;
D. Console.assert(sum3 (['hello' 2, 3, 4]) NaN);
Answer: (SHOW ANSWER)
Which method can be provide a visual representation of the list if users and to allow sorting by the
name or email attributes.
A. Console.group (userList);
B. Console.info (userlist);
C. Console.groupCollapsed (userslist);
D. Console,table (userslist);
Answer: (SHOW ANSWER)