March Sale Special Limited Time 70% Discount Offer - Ends in 0d 00h 00m 00s - Coupon code: 70percent

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

Salesforce Certified JavaScript Developer I (SP23) Questions and Answers

Question 1

Which code statement correctly retrieves and returns an object from localStorage?

Options:

A.

const retrieveFromLocalStorage = () =>{

return JSON.stringify(window.localStorage.getItem(storageKey));

}

B.

const retrieveFromLocalStorage = (storageKey) =>{

return window.localStorage.getItem(storageKey);

}

C.

const retrieveFromLocalStorage = (storageKey) =>{

return JSON.parse(window.localStorage.getItem(storageKey));

}

D.

const retrieveFromLocalStorage = (storageKey) =>{

return window.localStorage[storageKey];

}

Question 2

Given the code below:

01 function GameConsole (name) {

02 this.name = name;

03 }

04

05 GameConsole.prototype.load = function(gamename) {

06 console.log( ` $(this.name) is loading a game : $(gamename) …`);

07 )

08 function Console 16 Bit (name) {

09 GameConsole.call(this, name) ;

10 }

11 Console16bit.prototype = Object.create ( GameConsole.prototype) ;

12 //insert code here

13 console.log( ` $(this.name) is loading a cartridge game : $(gamename) …`);

14 }

15 const console16bit = new Console16bit(‘ SNEGeneziz ’);

16 console16bit.load(‘ Super Nonic 3x Force ’);

What should a developer insert at line 15 to output the following message using the

method ?

> SNEGeneziz is loading a cartridge game: Super Monic 3x Force . . .

Options:

A.

Console16bit.prototype.load(gamename) = function() {

B.

Console16bit.prototype.load = function(gamename) {

C.

Console16bit = Object.create(GameConsole.prototype).load = function

(gamename) {

D.

Console16bit.prototype.load(gamename) {

Question 3

Given the following code:

What will be the first four numbers logged?

Options:

A.

0012

B.

0112

C.

0122

D.

0123

Question 4

Given the following code:

let x = null;

console.log(typeof x);

What is the output?

Options:

A.

"object"

B.

"undefined"

C.

"null"

D.

"x"

Question 5

Which three browser specific APIs are available for developers to persist data between page loads ?

Choose 3 answers

Options:

A.

IIFEs

B.

indexedDB

C.

Global variables

D.

Cookies

E.

localStorage.

Question 6

Refer to the code below:

Const pi = 3.1415326,

What is the data type of pi?

Options:

A.

Double

B.

Number

C.

Decimal

D.

Float

Question 7

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

Question 8

Refer to the code below:

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

Options:

A.

Resolved1 Resolved2 Resolved3 Resolved4

B.

Rejected

C.

Rejected Resolved

D.

Rejected1 Rejected2 Rejected3 Rejected Rejected Rejected4

Question 9

Given HTML below:

Universal Container

Applied Shipping

Burlington Textiles

Which statement adds the priority = account CSS class to the universal Containers row ?

Options:

A.

Document .querySelector(‘#row-uc’).classes.push(‘priority-account’);

B.

Document .queryElementById(‘row-uc’).addclass(‘priority-account’);

C.

Document .querySelector(‘#row-uc’).classList.add(‘priority-account’);

D.

Document .querySelectorALL(‘#row-uc’).classList.add(‘priority-account’);

Question 10

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:

Options:

A.

console.assert( arr.length === 5 );

B.

arr.forEach(elem => console.assert(elem === 0)) ;

C.

console.assert(arr[0] === 0 && arr[ arr.length] === 0);

D.

console.assert (arr.length >0);

Question 11

A developer is leading the creation of a new browser application that will serve a single

page application. The team wants to use a new web framework Minimalsit.js. The Lead

developer wants to advocate for a more seasoned web framework that already has a

community around it.

Which two frameworks should the lead developer advocate for?

Choose 2 answers

Options:

A.

Vue

B.

Angular

C.

Koa

D.

Express

Question 12

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?

Options:

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

Question 13

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 14

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.’?

Options:

A.

Super.plate =plate;

B.

super(plate);

C.

This.plate =plate;

D.

Vehicle.plate = plate;

Question 15

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 16

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?

Options:

A.

setTimeout (formatName(), 5000, "John", "BDoe");

B.

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

C.

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

D.

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

Question 17

Given the following code:

Let x =(‘15’ + 10)*2;

What is the value of a?

Options:

A.

3020

B.

1520

C.

50

D.

35

Question 18

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.

window.location

B.

_filename

C.

_dirname

D.

this.path

Question 19

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

Question 20

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

Options:

A.

Use the document object instead of the window object.

B.

Assign variables to the global object.

C.

Create a new window object in the root file.

D.

Assign variables to module.exports and require them as needed.

Question 21

A developer writes the code below to calculate the factorial of a given number

function sum(number){

return number * sum(number-1);

}

sum(3);

what is the result of executing the code.

Options:

A.

0

B.

6

C.

Error

D.

-Infinity

Question 22

Refer to the code below:

const car = {

price:100,

getPrice:function(){

return this.price;

}

};

const customCar = Object.create(car);

customCar.price = 70;

delete customCar.price;const result = customCar.getPrice();

What is the value of result after the code executes?

Options:

A.

100

B.

undefined

C.

null

D.

70

Question 23

A test has a dependency on database.query. During the test the dependency is replaced

with an object called database with the method, query, that returns an array. The

developer needs to verify how many times the method was called and the arguments

used each time.

Which two test approaches describe the requirement?

Choose 2 answers

Options:

A.

Integration

B.

Black box

C.

White box

D.

Mocking

Question 24

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?

Options:

A.

node -i server.js

B.

node inspect server,js

C.

node server,js inspect

D.

node start inspect server,js

Question 25

Given the following code:

Counter = 0;

const logCounter = () => {

console.log(counter);

);

logCounter();

setTimeout(logCOunter, 1100);

setInterval(() => {

Counter++

logCounter();

}, 1000);

What is logged by the first four log statements?

Options:

A.

0 0 1 2

B.

0 1 2 3

C.

0 1 1 2

D.

0 1 2 2

Question 26

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

Options:

A.

var1 + var2

B.

var1.toString ( ) var2.toString ( )

C.

String (var1) .concat (var2)

D.

string.concat (var1 +var2)

Question 27

developer is trying to convince management that their team will benefit from using

Node.js for a backend server that they are going to create. The server will be a web server that

handles API requests from a website that the team has already built using HTML, CSS, and

JavaScript.

Which three benefits of Node.js can the developer use to persuade their manager?

Choose 3 answers:

Options:

A.

Installs with its own package manager to install and manage third-party libraries.

B.

Ensures stability with one major release every few years.

C.

Performs a static analysis on code before execution to look for runtime errors.

D.

Executes server-side JavaScript code to avoid learning a new language.

E.

Uses non-blocking functionality for performant request handling .

Question 28

Refer to the code below:

Which value can a developer expect when referencing country,capital,cityString?

Options:

A.

'London'

B.

undefined

C.

An error

D.

'NaN'

Question 29

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

Options:

A.

The line 05 assertion passes.

B.

The line 02 assertion passes.

C.

The line 02 assertion fails.

D.

The line 05 assertion fails.

Question 30

Which statement parses successfully?

Options:

A.

JSON. parse (""foo"');

B.

JSON.parse (""foo'");

C.

JSON.parse ("foo");

D.

JSON.parse ("foo");

Question 31

Refer the code below.

x=3.14;

function myfunction() {

"use strict";

y=x;

}

z=x;

myFunction();

Options:

Question 32

Refer to the code below:

const event = new CustomEvent(

//Missing Code

);

obj.dispatchEvent(event);

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

Options:

A.

‘Update’ , (

recordId : ‘123abc’

(

B.

‘Update’ , ‘123abc’

C.

{ type : ‘update’, recordId : ‘123abc’ }

D.

‘Update’ , {

Details : {

recordId : ‘123abc’

}

}

Question 33

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

Choose 3 answers !

Options:

A.

value == NaN

B.

Object.is(value, NaN)

C.

value === Number.NaN

D.

value ! == value

E.

Number.isNaN(value)