Labour Day Special Limited Time 65% Discount Offer - Ends in 0d 00h 00m 00s - Coupon code: suredis

Salesforce JavaScript-Developer-I Salesforce Certified JavaScript Developer I (SP23) Exam Practice Test

Salesforce Certified JavaScript Developer I (SP23) Questions and Answers

Testing Engine

  • Product Type: Testing Engine
$42  $119.99

PDF Study Guide

  • Product Type: PDF Study Guide
$36.75  $104.99
Question 1

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

Options:

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;

Question 2

Refer to the code:

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

Choose 3 answers:

Options:

A.

Name

B.

canTalk

C.

Type

D.

Owner

E.

Size

Question 3

A developer receives a comment from the Tech Lead that the code given below has

error:

const monthName = ‘July’;

const year = 2019;

if(year === 2019) {

monthName = ‘June’;

}

Which line edit should be made to make this code run?

Options:

A.

01 let monthName =’July’;

B.

02 let year =2019;

C.

02 const year = 2020;

D.

03 if (year == 2019) {

Question 4

What is the result of the code block?

Options:

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.

Question 5

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.

Given the code and the information the developer has, which code logs an error at boost

with an event?

Options:

A.

Server.catch ((server) => {

console.log(‘ERROR’, error);

});

B.

Server.error ((server) => {

console.log(‘ERROR’, error);

});

C.

Server.on (‘error’, (error) => {

console.log(‘ERROR’, error);

});

D.

Try{

server.start();

} catch(error) {

console.log(‘ERROR’, error);

}

Question 6

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

Options:

A.

Async runParallel () .then(data);

B.

runParallel ( ). done(function(data){

return data;

});

C.

runParallel () .then(data);

D.

runParallel () .then(function(data)

return data

Question 7

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 array after the code executes?

Options:

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]

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?

Options:

A.

super.size = size;

B.

ship.size size;

C.

super (size);

D.

this.size = size;

Question 9

A developer copied a JavaScript object:

How does the developer access dan's forstName,lastName? Choose 2 answers

Options:

A.

dan,name

B.

dan,firstname ( ) + dan, lastName ( )

C.

dan, firstName = dan.lastName

D.

dan,name ( )

Question 10

Universal Containers (UC) just launched a new landing page, but users complain that the website is slow. A developer found some functions any that might cause this problem. To verify this, the developer decides to execute everything and log the time each of these three suspicious functions consumes.

Which function can the developer use to obtain the time spent by every one of the three functions?

Options:

A.

console. timeLog ()

B.

console.timeStamp ()

C.

console.trace()

D.

console.getTime ()

Question 11

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

Options:

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

Question 12

Which three statements are true about promises ?

Choose 3 answers

Options:

A.

The executor of a new Promise runs automatically.

B.

A Promise has a .then() method.

C.

A fulfilled or rejected promise will not change states .

D.

A settled promise can become resolved.

E.

A pending promise can become fulfilled, settled, or rejected.

Question 13

Refer to the following array:

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

Which three options result in x evaluating as [3, 4, 5] ?

Choose 3 answers.

Options:

A.

Let x= arr.filter (( a) => (a<2));

B.

Let x= arr.splice(2,3);

C.

Let x= arr.slice(2);

D.

Let x= arr.filter((a) => ( return a>2 ));

E.

Let x = arr.slice(2,3);

Question 14

Which statement accurately describes the behaviour of the async/ await keyworks ?

Options:

A.

The associated class contains some asynchronous functions.

B.

The associated function will always return a promise

C.

The associated function can only be called via asynchronous methods

D.

The associated sometimes returns a promise.

Question 15

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:

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.

Options:

A.

Use the DOM inspector to prevent the load event to be fired.

B.

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

C.

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

D.

Use the browser console to execute a script that prevents the load event to be fired.

Question 16

Refer to the 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 missing code for the code to display 'The truck 123AB has a

weight of 5000lb.

Options:

A.

super(plate)

B.

super.plate = plate

C.

Vehicle.plate = plate

D.

this.plate = plate

Question 17

A developer at Universal Containers is creating their new landing page based on HTML, CSS, and JavaScript. The website includes multiple external resources that are loaded when the page is opened.

To ensure that visitors have a good experience, a script named personalizeWebsiteContent needs to be executed when the webpage is loaded and there is no need to wait for the resources to be available.

Which statement should be used to call personalizeWebsiteContent based on the above business requirement?

Options:

A.

windows,addEventListener('load', personalizeWebsiteContent);

B.

windows,addEventListener('DOMContent Loaded ', personalizeWebsiteContent);

C.

windows,addEventListener('onload', personalizeWebsiteContent);

D.

windows,addEventListener('onDOMCContentLoaded', personalizeWebsiteContent);

Question 18

A developer at Universal Containers creates a new landing page based on HTML, CSS, and

JavaScript TO ensure that visitors have a good experience, a script named personaliseContext

needs to be executed when the webpage is fully loaded (HTML content and all related files ), in

order to do some custom initialization.

Which statement should be used to call personalizeWebsiteContent based on the above

business requirement?

Options:

A.

document.addEventListener(‘’onDOMContextLoaded’, personalizeWebsiteContext);

B.

window.addEventListener(‘load’,personalizeWebsiteContext);

C.

window.addEventListener(‘onload’, personalizeWebsiteContext);

D.

Document.addEventListener(‘‘’DOMContextLoaded’ , personalizeWebsiteContext);

Question 19

Which statement accurately describes an aspect of promises?

Options:

A.

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

B.

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

C.

.then() cannot be added after a catch.

D.

.then() manipulates and returns the original promise.

Question 20

Which option is true about the strict mode in imported modules?

Options:

A.

Add the statement use non-strict, before any other statements in the module to enable

not-strict mode.

B.

You can only reference notStrict() functions from the imported module.

C.

Imported modules are in strict mode whether you declare them as such or not.

D.

Add the statement use strict =false; before any other statements in the module to enable

not- strict mode.

Question 21

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 nag is declared and assigned a value on line 03.

What is the value of msg when getAvailableabilityMessage (“newUserName”) is executed and get Availability (“newUserName”) returns true?

Options:

A.

"msg is not defined"

B.

"newUserName"

C.

"User-name available"

D.

undefined

Question 22

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

Options:

A.

let res = fizzbuzz(5);

console.assert ( res === ‘ ’ );

B.

let res = fizzbuzz(15);

console.assert ( res === ‘ fizzbuzz ’ )

C.

let res = fizzbuzz(Infinity);

console.assert ( res === ‘ ’ )

D.

let res = fizzbuzz(3);

console.assert ( res === ‘ buzz ’ )

Question 23

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 ?

Options:

A.

Object.const()

B.

Object.eval()

C.

Object.lock()

D.

Object.freeze()

Question 24

Which two console logs outputs NaN ?

Choose 2 answers

Options:

A.

console.log(10/ Number(‘5’));

B.

console.log(parseInt(‘two’));

C.

console.log(10/ ‘’five);

D.

console.log(10/0);

Question 25

Which three options show valid methods for creating a fat arrow function?

Choose 3 answers

Options:

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

Question 26

A developer implements a function that adds a few values.

Function sum(num) {

If (num == undefined) {

Num =0;

}

Return function( num2, num3){

If (num3 === undefined) {

Num3 =0 ;

}

Return num + num2 + num3;

}

}

Which three options can the developer invoke for this function to get a return value of 10 ?

Choose 3 answers

Options:

A.

Sum () (20)

B.

Sum (5, 5) ()

C.

sum() (5, 5)

D.

sum(5)(5)

E.

sum(10) ()

Question 27

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?

Options:

A.

1 growl method is created for Option A. 1000 growl methods are created for Option B.

B.

1000 growl method is created for Option A. 1 growl methods are created for Option B.

C.

1000 growl methods are created regardless of which option is used.

D.

1 growl method is created regardless of which option is used.

Question 28

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?

Options:

A.

Console.assert (await functionUnderTest(true), ‘ OK ’)

B.

Console.assert (await functionUnderTest(true), ‘ not OK ’)

C.

Console.assert (await functionUnderTest(true), ‘ not OK ’)

D.

Console.assert (await functionUnderTest(true), ‘OK’)

Question 29

Which two console logs output NaN?

Choose 2 answers | |

Options:

A.

console.log(10 / Number('5) ) ;

B.

console.log(parseInt ' ("two')) ;

C.

console.log(10 / 0);

D.

console.loeg(10 / 'five');

Question 30

Refer to the following code that performs a basic mathematical operation on a provided

input:

function calculate(num) {

Return (num +10) / 3;

}

How should line 02 be written to ensure that x evaluates to 6 in the line below?

Let x = calculate (8);

Options:

A.

Return Number((num +10) /3 );

B.

Return (Number (num +10 ) / 3;

C.

Return Integer(num +10) /3;

D.

Return Number(num + 10) / 3;

Question 31

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?

Options:

A.

console.timeLog()

B.

console.getTime()

C.

console.trace()

D.

console.timeStamp()

Question 32

Which two options are core Node.js modules?

Choose 2 answers

Options:

A.

worker

B.

isotream

C.

exception

D.

http

Question 33

Refer to the code below:

Considering that JavaScript is single-threaded, what is the output of line 08 after the code executes?

Options:

A.

10

B.

11

C.

12

D.

13