Summer Certification Sale 70% Discount Offer - Ends in 0d 00h 00m 00s - Coupon code: save70

Free and Premium Salesforce JavaScript-Developer-I Dumps Questions Answers

Salesforce Certified JavaScript Developer (JS-Dev-101) Questions and Answers

Question 1

A test searches for:

< button class= " blue " > Checkout < /button >

But the actual HTML is:

< button > Checkout < /button >

The test fails because it expects a class that no longer exists.

What type of test outcome is this?

Options:

A.

False negative

B.

True positive

C.

True negative

D.

False positive

Buy Now
Question 2

Refer to the following code:

01 let obj = {

02 foo: 1,

03 bar: 2

04 }

05 let output = []

06

07 for (let something of obj) {

08 output.push(something);

09 }

10

11 console.log(output);

What is the value of output on line 11?

Options:

A.

An error will occur due to the incorrect usage of the for_of statement on line 07.

B.

[1, 2]

C.

[ " foo " , " bar " ]

D.

[ " foo:1 " , " bar:2 " ]

Question 3

Given the code below:

01 const delay = async delay = > {

02 return new Promise((resolve, reject) = > {

03 console.log(1);

04 setTimeout(resolve, delay);

05 });

06 };

07

08 const callDelay = async () = > {

09 console.log(2);

10 const yup = await delay(1000);

11 console.log(3);

12 };

13

14 console.log(4);

15 callDelay();

16 console.log(5);

What is logged to the console?

Options:

A.

4 2 1 5 3

B.

4 2 1 5 3

C.

1 4 2 3 5

D.

4 5 1 2 3

Question 4

Which statement allows a developer to update the browser navigation history without a page refresh?

Options:

A.

window.customHistory.pushState(newStateObject, ' ' , null);

B.

window.history.createState(newStateObject, ' ' );

C.

window.history.pushState(newStateObject, ' ' , null);

D.

window.history.updateState(newStateObject, ' ' );

Question 5

Considering type coercion, what does the following expression evaluate to?

true + ' 13 ' + NaN

Options:

A.

' true13NaN '

B.

' 113NaN '

C.

14

D.

' true13 '

Question 6

A developer writes the code below 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.

function getAvailabilityMessage(item) {

if (getAvailability(item)) {

var msg = " Username available " ;

return msg;

}

}

Options:

A.

" msg is not defined "

B.

" newUserName "

C.

" Username available "

D.

undefined

Question 7

for (let number = 2; number < = 5; number += 1) {

// faster code statement here

}

Which statement meets the requirements to log an error when the Boolean statement evaluates to false?

Options:

A.

console.classy(number + 2 === 0);

B.

assert(number + 2 === 0);

C.

console.assert(number + 2 === 0);

D.

console.error(number + 2 === 0);

Question 8

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?

(With corrected typing errors: node_inspect → node inspect, node_start_inspect → node start inspect.)

Options:

A.

node start inspect server.js

B.

node inspect server.js

C.

node server.js --inspect

D.

node -i server.js

Question 9

Corrected code:

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 result after line 10 executes?

Options:

A.

" John Developer "

B.

" John undefined "

C.

Error: myFather.job is not a function

D.

" undefined Developer "

Question 10

A developer wrote the following code to test a sum3 function that takes in an array of numbers and returns the sum of the first three numbers in the array. The test passes:

01 let res = sum3([1, 2, 3]);

02 console.assert(res === 6);

03

04 res = sum3([1, 2, 3, 4]);

05 console.assert(res === 6);

A different developer made changes to the behavior of sum3 to instead sum all of the numbers present in the array.

Which two results occur when running the test on the updated sum3 function?

Options:

A.

The line 02 assertion fails.

B.

The line 05 assertion passes.

C.

The line 05 assertion fails.

D.

The line 02 assertion passes.

Question 11

A developer wants to use a module named universalContainerslib and then call functions from it. How should a developer import every function from the module and then call the functions foo and bar?

Options:

A.

import * as lib from ' /path/universalContainerslib.js ' ;

lib.foo();

lib.bar();

B.

import * from ' /path/universalContainerslib.js ' ;

universalContainerslib.foo();

universalContainerslib.bar();

C.

import all from ' /path/universalContainerslib.js ' ;

universalContainerslib.foo();

universalContainerslib.bar();

D.

import {foo, bar} from ' /path/universalContainerslib.js ' ;

foo();

bar();

Question 12

Given the code:

const copy = JSON.stringify([new String( ' false ' ), new Boolean(false), undefined]);

What is the value of copy?

Options:

A.

' [ " false " , false, null] '

B.

' [false, {}] '

C.

' [ " false " , false, undefined] '

D.

' [ " false " , {}] '

Question 13

A developer creates a new web server that uses Node.js. It imports a server library that uses events and callbacks for handling server functionality. The server library is imported with require and is made available to the code by a variable named server. The developer wants to log any issues that the server has while booting up.

Which code logs an error at boot time with an event?

Options:

A.

server.error((error) = > {

console.log( ' ERROR ' , error);

});

B.

server.catch((error) = > {

console.log( ' ERROR ' , error);

});

C.

try {

server.start();

} catch(error) {

console.log( ' ERROR ' , error);

}

D.

server.on( ' error ' , (error) = > {

console.log( ' ERROR ' , error);

});

Question 14

A developer wants to create a simple image upload using the File API.

HTML:

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

< img src= " " height= " 200 " alt= " Image preview... " / >

JavaScript:

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 }

Which code in lines 04 and 08 allows the selected local image to be displayed?

Options:

A.

04 const reader = new File();

08 if (file) reader.readAsDataURL(file);

B.

04 const reader = new FileReader();

08 if (file) reader.readAsDataURL(file);

C.

04 const reader = new FileReader();

08 if (file) URL.createObjectURL(file);

Question 15

Refer to the code snippet:

01 function getAvailableilityMessage(item) {

02 if (getAvailableility(item)) {

03 var msg = " Username available " ;

04 }

05 return msg;

06 }

What is the return value of msg when getAvailableilityMessage( " newUserName " ) is executed and getAvailableility( " newUserName " ) returns false?

Options:

A.

" newUserName "

B.

" msg is not defined "

C.

undefined

D.

" Username available "

Question 16

Refer to the code:

01 function execute() {

02 return new Promise((resolve, reject) = > reject());

03 }

04 let promise = execute();

05

06 promise

07 .then(() = > console.log( ' Resolved1 ' ))

08 .then(() = > console.log( ' Resolved2 ' ))

09 .then(() = > console.log( ' Resolved3 ' ))

10 .catch(() = > console.log( ' Rejected ' ))

11 .then(() = > console.log( ' Resolved4 ' ));

What is the result when the Promise in the execute function is rejected?

Options:

A.

Resolved1 Resolved2 Resolved3 Rejected Resolved4

B.

Rejected

C.

Resolved1 Resolved2 Resolved3 Resolved4

D.

Rejected Resolved4

Question 17

Refer to the code below:

01 let timedFunction = () = > {

02 console.log( ' Timer called. ' );

03 };

04

05 let timerId = setInterval(timedFunction, 1000);

Which statement allows a developer to cancel the scheduled timed function?

Options:

A.

clearInterval(timerId);

B.

removeInterval(timerId);

C.

removeInterval(timedFunction);

D.

clearInterval(timedFunction);

Question 18

Refer to the code below:

01 new Promise((resolve, reject) = > {

02 const fraction = Math.random();

03 if (fraction > 0.5) reject( ' fraction > 0.5, ' + fraction);

04 resolve(fraction);

05 })

06 .then(() = > console.log( ' resolved ' ))

07 .catch((error) = > console.error(error))

08 .finally(() = > console.log( ' when am I called? ' ));

When does Promise.finally on line 08 get called?

Options:

A.

When rejected

B.

When resolved and settled

C.

When resolved

D.

When resolved or rejected

Question 19

01 function Animal(size, type) {

02 this.type = type || ' Animal ' ;

03 this.canTalk = false;

04 }

05

06 Animal.prototype.speak = function() {

07 if (this.canTalk) {

08 console.log( " It spoke! " );

09 }

10 };

11

12 let Pet = function(size, type, name, owner) {

13 Animal.call(this, size, type);

14 this.size = size;

15 this.name = name;

16 this.owner = owner;

17 }

18

19 Pet.prototype = Object.create(Animal.prototype);

20 let pet1 = new Pet();

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

Options:

A.

speak

B.

owner

C.

canTalk

D.

name

E.

type

Question 20

A developer imports:

import printPrice from ' /path/PricePrettyPrint.js ' ;

What must be true about printPrice for this import to work?

Options:

A.

printPrice must be a named export

B.

printPrice must be an all export

C.

printPrice must be the default export

D.

printPrice must be a multi export

Question 21

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?

Options:

A.

setTimeout(function() {

try {

countSheep();

} catch (e) {

handleError(e);

}

}, 1000);

B.

try {

countSheep();

} finally {

handleError(e);

}

C.

try {

countSheep();

} handleError (e){

catch(e);

}

D.

try {

setTimeout(function() {

countSheep();

}, 1000);

} catch (e) {

handleError(e);

}

Question 22

A developer wants to use a module called DatePrettyPrint.

This module exports one default function called printDate().

How can the developer import and use printDate()?

Options:

A.

import DatePrettyPrint() from ' /path/DatePrettyPrint.js ' ;

printDate();

B.

import DatePrettyPrint from ' /path/DatePrettyPrint.js ' ;

DatePrettyPrint.printDate();

C.

import printDate from ' /path/DatePrettyPrint.js ' ;

DatePrettyPrint.printDate();

D.

import printDate from ' /path/DatePrettyPrint.js ' ;

printDate();

Question 23

After user acceptance testing, the developer is asked to change the webpage background based on the user’s location. It works on the developer’s computer but not on the tester’s machine.

Which two actions will help determine accurate results?

Options:

A.

The tester should disable their browser cache.

B.

The developer should inspect their browser refresh settings.

C.

The tester should clear their browser cache.

D.

The developer should rework the code.

Question 24

Refer to the code below (assuming Promise.race is intended):

let cat3 = new Promise(resolve = >

setTimeout(resolve, 3000, " Cat 3 completes " )

);

Promise.race([cat1, cat2, cat3])

.then(value = > {

let result = `${value} the race.`;

})

.catch(err = > {

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

});

(Assuming cat1 and cat2 are similar to earlier examples: cat2 resolves fastest.)

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

Options:

A.

Car 2 completed the race.

B.

Car 1 crashed on the race.

C.

Race is cancelled.

D.

Car 3 completed the race.

Question 25

Function to test:

01 const sum3 = (arr) = > {

02 if (!arr.length) return 0;

03 if (arr.length === 1) return arr[0];

04 if (arr.length === 2) return arr[0] + arr[1] ;

05 return arr[0] + arr[1] + arr[2];

06 };

Which two assert statements are valid tests for this function?

Options:

A.

console.assert(sum3([1, ' 2 ' ]) == 12);

B.

console.assert(sum3([ ' hello ' , 2, 3, 4]) === NaN);

C.

console.assert(sum3([-3, 2]) === -1);

D.

console.assert(sum3([0]) === 0);

Question 26

Refer to the following object:

const dog = {

firstName: ' Beau ' ,

lastName: ' Boo ' ,

get fullName() {

return this.firstName + ' ' + this.lastName;

}

};

How can a developer access the fullName property for dog?

Options:

A.

dog.fullName

B.

dog.fullName()

C.

dog.get.fullName

D.

dog.function.fullName()

Question 27

Given the following code:

01 let x = null;

02 console.log(typeof x);

What is the output of line 02?

Options:

A.

" object "

B.

" undefined "

C.

" x "

D.

" null "

Question 28

Given the JavaScript below:

01 function filterDOM(searchString){

02 const parsedSearchString = searchString & & searchString.toLowerCase();

03 document.querySelectorAll( ' .account ' ).forEach(account = > {

04 const accountName = account.innerHTML.toLowerCase();

05 account.style.display = accountName.includes(parsedSearchString) ? /* Insert code here */;

06 });

07 }

Which code should replace the placeholder comment on line 05 to hide accounts that do not match the search string?

Options:

A.

' block ' : ' none '

B.

' hidden ' : ' visible '

C.

' visible ' : ' hidden '

D.

' none ' : ' block '

Question 29

Refer to the code below:

01 function changeValue(param) {

02 param = 5;

03 }

04 let a = 10;

05 let b = a;

06

07 changeValue(b);

08 const result = a + ' - ' + b;

What is the value of result when the code executes?

Options:

A.

5-5

B.

5-10

C.

10-5

D.

10-10

Question 30

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 " : " user01@universalcontainers.demo " ,

04 " age " : 25

05 };

Which two options access the email attribute in the object?

Options:

A.

userInformation.email

B.

userInformation.get( " email " )

C.

userInformation[ " email " ]

D.

userInformation[email]

Question 31

Refer to the code below:

let productSKU = ' 8675309 ' ;

A developer has a requirement to generate SKU numbers that are always 19 characters long, starting with ' sku ' , and padded with zeros.

Which statement assigns the value sku000000008675309?

Options:

A.

productSKU = productSKU.padEnd(16, ' 0 ' ).padStart( ' sku ' );

B.

productSKU = productSKU.padStart(16, ' 0 ' ).padStart(19, ' sku ' );

C.

productSKU = productSKU.padEnd(16, ' 0 ' ).padStart(19, ' sku ' );

D.

productSKU = productSKU.padStart(19, ' 0 ' ).padStart( ' sku ' );

Question 32

Which actions can be done using the JavaScript browser console?

Options:

A.

Run code that’s not related to the page

B.

View and change the DOM of the page

C.

Display a report showing the performance of a page

D.

Change the DOM and the JavaScript code of the page

E.

View and change security cookies

Question 33

Which statement accurately describes an aspect of promises?

Options:

A.

Arguments for the callback function passed to .then() are optional.

B.

.then() cannot be added after a catch.

C.

.then() manipulates and returns the original promise.

D.

In a .then() function, returning results is not necessary since callbacks will catch the result of a previous promise.

Question 34

Given the JavaScript below:

function onLoad() {

console.log( " Page has loaded! " );

}

Where can the developer see the log statement after loading the page in the browser?

Options:

A.

On the browser JavaScript console

B.

On the terminal console running the web server

C.

In the browser performance tools log

D.

On the webpage console log

Question 35

Given the HTML below:

< div >

< div id= " row-uc " > Universal Containers < /div >

< div id= " row-as " > Applied Shipping < /div >

< div id= " row-bt " > Burlington Textiles < /div >

< /div >

Which statement adds the priority-account CSS class to the Applied Shipping row?

Options:

A.

document.querySelectorAll( ' #row-as ' ).classList.add( ' priority-account ' );

B.

document.querySelector( ' #row-as ' ).classList.add( ' priority-account ' );

C.

document.querySelector( ' #row-as ' ).classes.push( ' priority-account ' );

D.

document.getElementById( ' row-as ' ).addClass( ' priority-account ' );

Question 36

A page loads 50+ < div class= " ad-library-item " > elements, all ads.

Developer wants to quickly and temporarily remove them.

Options:

Options:

A.

Use the browser console to execute a script that prevents the load event from firing.

B.

Use the DOM inspector to prevent the load event from firing.

C.

Use the browser console to execute a script that removes all elements containing the class ad-library-item.

D.

Use the DOM inspector to remove all elements containing the class ad-library-item.

Question 37

A team at Universal Containers works on a big project and uses Yarn to deal with the project’s dependencies. A developer added a dependency to manipulate dates and pushed the updates to the remote repository. The rest of the team complains that the dependency does not get downloaded when they execute yarn.

What could be the reason for this?

Options:

A.

The developer missed the option --add when adding the dependency.

B.

The developer added the dependency as a dev dependency, and NODE_ENV is set to production.

C.

The developer added the dependency as a dev dependency, and YARN_ENV is set to production.

D.

The developer missed the option --save when adding the dependency.

Question 38

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?

Options:

A.

03 try {

04 handleObjectValue(x);

05 } catch(error) {

06 handleError(error);

07 } then {

08 getNextValue();

09 }

B.

03 try {

04 handleObjectValue(x);

05 getNextValue();

06 } catch(error) {

07 handleError(error);

08 }

C.

03 try {

04 handleObjectValue(x);

05 } catch(error) {

06 handleError(error);

07 }

08 getNextValue();

D.

03 try {

04 handleObjectValue(x);

05 } catch(error) {

06 handleError(error);

07 } finally {

08 getNextValue();

09 }

Question 39

A developer is leading the creation of a new web server for their team that will fulfill API requests from an existing client. The team wants a web server that runs on Node.js, and they want to use the new web framework Minimalist.js. The lead developer wants to advocate for a more seasoned back-end framework that already has a community around it.

Which two frameworks could the lead developer advocate for?

Options:

A.

Angular

B.

Next

C.

Gatsby

D.

Next.js

Question 40

Refer to the following object:

01 const cat = {

02 firstName: ' Fancy ' ,

03 lastName: ' Whiskers ' ,

04 get fullName(){

05 return this.firstName + ' ' + this.lastName;

06 }

07 };

How can a developer access the fullName property for cat?

Options:

A.

cat.fullName()

B.

cat.get.fullName

C.

cat.function.fullName()

D.

cat.fullName

Question 41

Given a value, which two options can a developer use to detect if the value is NaN?

Options:

A.

value === Number.NaN

B.

value == NaN

C.

isNaN(value)

D.

Object.is(value, NaN)

Question 42

Given a value, which three options can a developer use to detect if the value is NaN?

Options:

A.

value === Number.NaN

B.

value == NaN

C.

Object.is(value, NaN)

D.

value !== value

E.

Number.isNaN(value)

Question 43

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?

Options:

A.

__filename

B.

window.location

C.

this.path

D.

__dirname

Question 44

Which two implementations of utils.js support foo and bar?

Options:

A.

const foo = () = > { return ' foo ' ; };

const bar = () = > { return ' bar ' ; };

export { foo, bar };

B.

const foo = () = > { return ' foo ' ; };

const bar = () = > { return ' bar ' ; };

export default { foo, bar };

C.

import { foo, bar } from " ./helpers/utils.js " ;

export { foo, bar };

D.

export default class {

foo() { return ' foo ' ; }

bar() { return ' bar ' ; }

}