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

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

Questions 4

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?

Options:

A.

const server = require( ' secure-server ' );

B.

const tls = require( ' tls ' );

C.

const http = require( ' http ' );

D.

const https = require( ' https ' );

Buy Now
Questions 5

Code:

01 const sayHello = (name) = > {

02 console.log( ' Hello ' , name);

03 };

04

05 const world = () = > {

06 return ' World ' ;

07 };

08

09 sayHello(world);

This does not print " Hello World " .

What change is needed?

Options:

A.

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

B.

Change line 7 to }();

C.

Change line 9 to sayHello(world)();

D.

Change line 5 to function world() {

Buy Now
Questions 6

A team at Universal Containers works on a big project and uses yarn to manage 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 added the dependency as a dev dependency, and YARN_ENV is set to production.

B.

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

C.

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

D.

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

Buy Now
Questions 7

A class was written to represent items for purchase in an online store, and a second class representing items that are on sale at a discounted price. The constructor sets the name to the first value passed in. There is a new requirement for a developer to implement a description method that will return a brief description for Item and SaleItem.

01 let regItem = new Item( ' Scarf ' , 55);

02 let saleItem = new SaleItem( ' Shirt ' , 80, .1);

03 Item.prototype.description = function() { return ' This is a ' + this.name; }

04 console.log(regItem.description());

05 console.log(saleItem.description());

06

07 SaleItem.prototype.description = function() { return ' This is a discounted ' + this.name; }

What is the output when executing the code above?

Options:

A.

This is a Scarf

Uncaught TypeError: saleItem.description is not a function

This is a Scarf

This is a discounted Shirt

B.

This is a Scarf

This is a Shirt

This is a Scarf

This is a discounted Shirt

C.

This is a Scarf

This is a Shirt

This is a discounted Scarf

This is a discounted Shirt

D.

This is a Scarf

Uncaught TypeError: saleItem.description is not a function

This is a Shirt

This is a discounted Shirt

Buy Now
Questions 8

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

Buy Now
Questions 9

What are two unique features of fat-arrow functions compared to normal function definitions?

Options:

A.

If the function has a single expression in the function body, the expression will be evaluated and implicitly returned.

B.

The function uses the this from the enclosing scope.

C.

The function receives an argument called parentThis, giving the enclosing lexical scope.

D.

The function generates its own this making it useful for separating scope.

Buy Now
Questions 10

Refer to the code:

const pi = 3.1415926;

What is the data type of pi?

Options:

A.

Float

B.

Double

C.

Decimal

D.

Number

Buy Now
Questions 11

Which statement accurately describes the behavior of the async/await keywords?

Options:

A.

The associated function sometimes returns a promise.

B.

The associated function can only be called via asynchronous methods.

C.

The associated class contains some asynchronous functions.

D.

The associated function is asynchronous, but acts like synchronous code.

Buy Now
Questions 12

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 "

Buy Now
Questions 13

Given two expressions var1 and var2, what are two valid ways to return the concatenation of the two expressions and ensure it is data type string?

Options:

A.

String(var1).concat(var2)

B.

String.concat(var1 + var2)

C.

var1 + var2

D.

var1.toString() + var2.toString()

Buy Now
Questions 14

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)

Buy Now
Questions 15

A Node.js server library uses events and callbacks. The developer wants to log any issues the server has at boot time.

Which code logs an error with an event?

Options:

A.

server.catch( ' error) = > {

console.log( ' ERROR ' , error);

});

B.

server.error( ' error) = > {

console.log( ' ERROR ' , error);

});

C.

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

console.log( ' ERROR ' , error);

});

D.

try {

server.start();

} catch(error) {

console.log( ' ERROR ' , error);

}

Buy Now
Questions 16

Refer to the code below:

01 let sayHello = () = > {

02 console.log( ' Hello, World! ' );

03 };

Which code executes sayHello once , two minutes from now?

Options:

A.

delay(sayHello, 120000);

B.

setTimeout(sayHello, 120000);

C.

setTimeout(sayHello(), 120000);

D.

setInterval(sayHello, 120000);

Buy Now
Questions 17

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

Buy Now
Questions 18

Corrected code:

let obj = {

foo: 1,

bar: 2

};

let output = [];

for (let something in obj) {

output.push(something);

}

console.log(output);

What is the output of line 11?

Options:

A.

[ " bar " , " foo " ]

B.

[1, 2]

C.

[ " foo " , " bar " ]

D.

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

Buy Now
Questions 19

Why does second have access to variable a?

Options:

A.

Inner function ' s scope

B.

Outer function ' s scope

C.

Prototype Chain

D.

Hoisting

Buy Now
Questions 20

Refer to the code below:

01 let o = {

02 get js() {

03 let city1 = String( ' St. Louis ' );

04 let city2 = String( ' New York ' );

05

06 return {

07 firstCity: city1.toLowerCase(),

08 secondCity: city2.toLowerCase(),

09 }

10 }

11 }

What value can a developer expect when referencing o.js.secondCity?

Options:

A.

undefined

B.

An error

C.

' New York '

D.

' new york '

Buy Now
Questions 21

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.

Buy Now
Questions 22

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
Questions 23

Given the code below:

01 setCurrentUrl();

02 console.log( " The current URL is: " + url);

03

04 function setCurrentUrl() {

05 url = window.location.href;

06 }

What happens when the code executes?

Options:

A.

The url variable has global scope and line 02 throws an error.

B.

The url variable has global scope and line 02 executes correctly.

C.

The url variable has local scope and line 02 executes correctly.

D.

The url variable has local scope and line 02 throws an error.

Buy Now
Questions 24

Code:

01 let array = [1, 2, 3, 4, 4, 5, 4, 4];

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

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

04 array.splice(i, 1);

05 i--;

06 }

07 }

What is the value of array after execution?

Options:

A.

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

B.

[1,2,3,5]

C.

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

D.

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

Buy Now
Questions 25

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

Buy Now
Questions 26

Refer to the code:

01 const exec = (item, delay) = >

02 new Promise(resolve = > setTimeout(() = > resolve(item), delay));

03

04 async function runParallel() {

05 const [result1, result2, result3] = await Promise.all(

06 [exec( ' x ' , ' 100 ' ), exec( ' y ' , ' 500 ' ), exec( ' z ' , ' 100 ' )]

07 );

08 return `parallel is done: ${result1}${result2}${result3}`;

09 }

Which two statements correctly execute runParallel()?

Options:

A.

async runParallel().then(data);

B.

runParallel().then(function(data){

return data;

});

C.

runParallel().done(function(data){

return data;

});

D.

runParallel().then(data);

Buy Now
Questions 27

Refer to the code below:

< html >

< body >

< div id= " logo " > Hello Logo! < /div >

< button id= " test " > Click me < /button >

< /body >

< script >

function printMessage(event) {

console.log( ' This is a test message ' );

}

let el = document.getElementById( ' test ' );

el.addEventListener( " click " , printMessage, false);

< /script >

< /html >

Which action should be done?

Options:

A.

Add event.removeEventListener(); to window.onload event handler

B.

Add event.removeEventListener(); to printMessage function

C.

Add event.stopPropagation(); to printMessage function

D.

Add event.stopPropagation(); to window.onload event handler

Buy Now
Questions 28

Refer to the code below:

class Student {

constructor(name) {

this._name = name;

}

displayGrade() {

console.log(`${this._name} got 70% on test.`);

}

}

class GraduateStudent extends Student {

constructor(name) {

super(name);

this._name = " Graduate Student " + name;

}

displayGrade() {

console.log(`${this._name} got 100% on test.`);

}

}

let student = new GraduateStudent( " Jane " );

student.displayGrade();

What is the console output?

Options:

A.

Better student Jackie got 70% on test.

B.

Uncaught ReferenceError

C.

Graduate Student Jane got 100% on test.

D.

Jackie got 70% on test.

Buy Now
Questions 29

A developer implements a function that adds a few values.

function sum(num1, num2, num3) {

if (num3 === undefined) {

num3 = 0;

}

return num1 + num2 + num3;

}

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

Options:

A.

sum(5)(5);

B.

sum()(10);

C.

sum(5, 5, 0);

D.

sum(10, 0);

E.

sum(5, 2, 3);

Buy Now
Questions 30

Given the code below:

let numValue = 1982;

Which three code segments result in a correct conversion from number to string?

Options:

A.

let strValue = numValue.toText();

B.

let strValue = String(numValue);

C.

let strValue = ' ' + numValue;

D.

let strValue = numValue.toString();

E.

let strValue = (String)numValue;

Buy Now
Questions 31

A developer creates a class that represents a news story based on the requirements that a Story should have a body, author, and view count. The code is shown below:

01 class Story {

02 // Insert code here

03 this.body = body;

04 this.author = author;

05 this.viewCount = viewCount;

06 }

07 }

Which statement should be inserted in the placeholder on line 02 to allow for a variable to be set to a new instance of a Story with the three attributes correctly populated?

Options:

A.

constructor() {

B.

super(body, author, viewCount) {

C.

function Story(body, author, viewCount) {

D.

constructor(body, author, viewCount) {

Buy Now
Questions 32

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]

Buy Now
Questions 33

Given the code below:

01 function Person(name, email) {

02 this.name = name;

03 this.email = email;

04 }

05

06 const john = new Person( ' John ' , ' john@email.com ' );

07 const jane = new Person( ' Jane ' , ' jane@email.com ' );

08 const emily = new Person( ' Emily ' , ' emily@email.com ' );

09

10 let usersList = [john, jane, emily];

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?

Options:

A.

console.table(usersList);

B.

console.group(usersList);

C.

console.groupCollapsed(usersList);

D.

console.info(usersList);

Buy Now
Questions 34

01 function Monster() { this.name = ' hello ' ; };

02 const m = Monster();

What happens due to the missing new keyword?

Options:

A.

The m variable is assigned the correct object.

B.

window.name is assigned to ' hello ' and the variable m remains undefined.

C.

window.m is assigned the correct object.

D.

The m variable is assigned the correct object but this.name remains undefined.

Buy Now
Questions 35

Which three actions can the code execute in the browser console?

Options:

A.

Run code that is not related to the page.

B.

View and change security cookies.

C.

Display a report showing the performance of a page.

D.

View, change, and debug the JavaScript code of the page.

E.

View and change the DOM of the page.

Buy Now
Questions 36

Refer to the code below:

01 x = 3.14;

02

03 function myFunction() {

04 ' use strict ' ;

05 y = x;

06 }

07

08 z = x;

09 myFunction();

Considering the implications of ' use strict ' on line 04, which three statements describe the execution of the code?

Options:

A.

' use strict ' is hoisted, so it has an effect on all lines.

B.

z is equal to 3.14.

C.

' use strict ' has an effect between line 04 and the end of the file.

D.

' use strict ' has an effect only on line 05.

E.

Line 05 throws an error.

Buy Now
Questions 37

A developer has 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 nor 5.

Which two test cases properly test scenarios for the fizzbuzz function?

Options:

A.

let res = fizzbuzz(3);

console.assert(res === ' buzz ' );

B.

let res = fizzbuzz(15);

console.assert(res === ' fizzbuzz ' );

C.

let res = fizzbuzz(NaN);

console.assert(isNaN(res));

D.

let res = fizzbuzz(Infinity);

console.assert(res === ' ' );

Buy Now
Questions 38

Refer to the code below:

flag();

function flag() {

console.log( ' flag ' );

}

const anotherFlag = () = > {

console.log( ' another flag ' );

}

anotherFlag();

What is result of the code block?

Options:

A.

The console logs only ' flag ' .

B.

An error is thrown.

C.

The console logs ' flag ' and then an error is thrown.

D.

The console logs ' flag ' and ' another flag ' .

Buy Now
Questions 39

Value of:

true + 3 + ' 100 ' + null

Options:

A.

" 4100null "

B.

104

C.

" 4100 "

D.

" 2200null "

Buy Now
Questions 40

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

Options:

A.

localStorage

B.

indexedDB

C.

cookies

D.

global variables

E.

IIFEs

Buy Now
Questions 41

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 '

Buy Now
Questions 42

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

true + ' 13 ' + NaN

Options:

A.

' true13NaN '

B.

' 113NaN '

C.

14

D.

' true13 '

Buy Now
Questions 43

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

Buy Now
Questions 44

At Universal Containers, every team has its own way of copying JavaScript objects. The code snippet shows an implementation from one team:

01 function Person() {

02 this.firstName = " John " ;

03 this.lastName = " Doe " ;

04 this.name = () = > {

05 console.log( ' Hello ${this.firstName} ${this.lastName} ' );

06 }

07 }

08

09 const john = new Person();

10 const dan = JSON.parse(JSON.stringify(john)); // (intended deep copy)

11 dan.firstName = ' Dan ' ;

12 dan.name();

(Original line 10 is logically intended to be JSON.parse(JSON.stringify(john)) to perform a JSON clone.)

What is the output of the code execution?

Options:

A.

Hello John Doe

B.

Hello Dan Doe

C.

TypeError: dan.name is not a function

D.

Hello Dan

Buy Now
Exam Name: Salesforce Certified JavaScript Developer (JS-Dev-101)
Last Update: Jun 26, 2026
Questions: 219
JavaScript-Developer-I pdf

JavaScript-Developer-I PDF

$25.5  $84.99
JavaScript-Developer-I Engine

JavaScript-Developer-I Testing Engine

$30  $99.99
JavaScript-Developer-I PDF + Engine

JavaScript-Developer-I PDF + Testing Engine

$40.5  $134.99