Winter Special Limited Time 65% Discount Offer - Ends in 0d 00h 00m 00s - Coupon code: myex65

Home > Salesforce > Salesforce Developer > JavaScript-Developer-I

JavaScript-Developer-I Salesforce Certified JavaScript Developer I (SU24) Question and Answers

Question # 4

Which javascript methods can be used to serialize an object into a string and deserialize

a JSON string into an object, respectively?

A.

JSON.stringify and JSON.parse

B.

JSON.serialize and JSON.deserialize

C.

JSON.encode and JSON.decode

D.

JSON.parse and JSON.deserialize

Full Access
Question # 5

Refer to the following code:

Full Access
Question # 6

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”, title: “javaScript}

Undefined

C.

{author: “Robert”, title: “javaScript}

{author: “Robert”, title: “javaScript}

D.

{author: “Robert”}

{author: “Robert”, title: “javaScript}

Full Access
Question # 7

The developer has a function that prints “Hello” to an input name. To test this, thedeveloper created a function that returns “World”. However the following snippet does not print “ Hello World”.

What can the developer do to change the code to print “Hello World” ?

A.

Change line 7 to ) () ;

B.

Change line 2 to console.log(‘Hello’ , name() );

C.

Change line 9 to sayHello(world) ();

D.

Change line 5 to function world ( ) {

Full Access
Question # 8

Refer to the following code:

Which statement should be added to line 09 for the code to display. The boat has a capacity of 10 people?

A.

super.size = size;

B.

ship.size size;

C.

super (size);

D.

this.size = size;

Full Access
Question # 9

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 functions foo

and bar ?

A.

import * ad lib from ‘/path/universalContainersLib.js’;

lib.foo();

lib.bar();

B.

import (foo, bar) from ‘/path/universalContainersLib.js’;

foo();

bar();

C.

import all from ‘/path/universalContaineraLib.js’;

universalContainersLib.foo();

universalContainersLib.bar();

D.

import * from ‘/path/universalContaineraLib.js’;

universalContainersLib.foo();

universalContainersLib.bar();

Full Access
Question # 10

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.

Returns 0

B.

Throws an error

C.

Returns 10

D.

Returns NaN

Full Access
Question # 11

Given the following code:

What will be the first four numbers logged?

A.

0012

B.

0112

C.

0122

D.

0123

Full Access
Question # 12

Refer to the code snippet below:

Let array = [1, 2, 3, 4, 4, 5, 4, 4];

For (let i =0; i < array.length; i++){

if (array[i] === 4) {

array.splice(i, 1);

}

}

What is the value of the array after the code executes?

A.

[1, 2, 3, 4, 5, 4, 4]

B.

[1, 2, 3, 4, 4, 5, 4]

C.

[1, 2, 3, 4, 5, 4]

D.

[1, 2, 3, 5]

Full Access
Question # 13

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.timeLog()

B.

console.getTime()

C.

console.trace()

D.

console.timeStamp()

Full Access
Question # 14

Refer to the following code:

Which two statement could be inserted at line 17 to enable the function call on line 18?

Choose 2 answers

A.

Object.assign (leo, tony);

B.

Object.assign (leo. Tiger);

C.

leo.roar = () => { console.log('They\'re pretty good!'); );

D.

leo.prototype.roar = ( ) =>( console.log('They\'re pretty good!'); };

Full Access
Question # 15

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.

ReferenceError: eyeColor is not defined

B.

ReferenceError: assignment to undeclared variable “Person”

C.

Developer

D.

Undefined

Full Access
Question # 16

A developer has the following array of hourly wages:

Let arr = (8, 5, 9, 75, 11, 25, 7, 75, , 13, 25);

For workers making less than $10 an hour rate should be multiple by 1.25 and returned in a new array.

How should the developer implement the request?

A.

let arrl = arr.filter((val) => val < 10).map((num) -> num = 1.25);

B.

let arrl = arr .rr.acArray ((val) => ( val < 10 )) ,map((num) => { num * 1.25 ));

C.

let arrl = arr-map((num) => { return ran * 1.25 }).filter((val) -> { return val < 10));

D.

let arrl = arr.filterBy((val) => val < 10 ).aapBy<(num) -> num = ..25 );

Full Access
Question # 17

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", "BDoe");

B.

setTimeout (formatName('John', ‘'Doe'), 5000);

C.

setTimout(() => { formatName("John', 'Doe') }, 5000);

D.

setTimeout ('formatName', 5000, 'John", "Doe');

Full Access
Question # 18

A developer needs to test this function:

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 the function?

Choose 2 answers

A.

console.assert(sum3(1, ‘2’)) == 12);

B.

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

C.

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

D.

console.assert(sum3(‘hello’, 2, 3, 4)) === NaN);

Full Access
Question # 19

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 A

B.

Option B

C.

Option C

D.

Option D

Full Access
Question # 20

Which two options are core Node.js modules?

Choose 2 answers

A.

worker

B.

isotream

C.

exception

D.

http

Full Access
Question # 21

A developer has a web server running with Node.js. The command to start the web server is node server.js. The web server started having

latency issues. Instead of a one second turnaround for web requests, the developer now sees a five second turnaround.

Which command can the web developer run to see what the module is doing during the latency period?

A.

NODE_DEBUG=true node server.js

B.

DEBUG=http, https node server.js

C.

NODE_DEBUG=http,https node server.js

D.

DEBUG=true node server.js

Full Access
Question # 22

Refer to following code:

class Vehicle {

constructor(plate) {

This.plate =plate;

}

}

Class Truck extends Vehicle {

constructor(plate, weight) {

//Missing code

This.weight = weight;

}

displayWeight() {

console.log(‘The truck ${this.plate} has a weight of ${this.weight} lb.’);}}

Let myTruck = new Truck(‘123AB’, 5000);

myTruck.displayWeight();

Which statement should be added to line 09 for the code to display ‘The truck 123AB has a

weight of 5000lb.’?

A.

Super.plate =plate;

B.

super(plate);

C.

This.plate =plate;

D.

Vehicle.plate = plate;

Full Access
Question # 23

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 -i server.js

B.

node inspect server,js

C.

node server,js inspect

D.

node start inspect server,js

Full Access
Question # 24

What is the result of the code block?

A.

The console logs only ‘flag’.

B.

The console logs ‘flag’ and another flag.

C.

An error is thrown.

D.

The console logs ‘flag’ and then an error is thrown.

Full Access
Question # 25

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

Choose 3 answers !

A.

value == NaN

B.

Object.is(value, NaN)

C.

value === Number.NaN

D.

value ! == value

E.

Number.isNaN(value)

Full Access
Question # 26

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, and the test passes.

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

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

Choose 2 answers

A.

The line 05 assertion passes.

B.

The line 02 assertion passes.

C.

The line 02 assertion fails.

D.

The line 05 assertion fails.

Full Access
Question # 27

Which code statement below correctly persists an objects in local Storage ?

A.

const setLocalStorage = (storageKey, jsObject) => {

window.localStorage.setItem(storageKey, JSON.stringify(jsObject));

}

B.

const setLocalStorage = ( jsObject) => {

window.localStorage.connectObject(jsObject));

}

C.

const setLocalStorage = ( jsObject) => {

window.localStorage.setItem(jsObject);

}

D.

const setLocalStorage = (storageKey, jsObject) => {

window.localStorage.persist(storageKey, jsObject);

}

Full Access
Question # 28

Refer to the following object.

How can a developer access the fullName property for dog?

A.

Dog.fullName

B.

Dog.fullName ( )

C.

Dog, get, fullName

D.

Dog, function, fullName

Full Access
Question # 29

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?

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

Full Access
Question # 30

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.info(usersList) ;

D.

console.groupCol lapsed (usersList) ;

Full Access
Question # 31

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.

Non-primitive values are mutable.

B.

Non-primitive values are immutable.

C.

Primitive values are mutable.

D.

Primitive values are immutable.

Full Access
Question # 32

Which statement parses successfully?

A.

JSON. parse (""foo"');

B.

JSON.parse (""foo'");

C.

JSON.parse ("foo");

D.

JSON.parse ("foo");

Full Access
Question # 33

Refer to the code below:

function changeValue(param) {

Param =5;

}

Let a =10;

Let b =5;

changeValue(b);

Const result = a+ “ - ”+ b;

What is the value of result when code executes?

A.

10 -10

B.

5 -5

C.

5 - 10

D.

10 - 5

Full Access