Pre-Summer Limited Time 70% Discount Offer - Ends in 0d 00h 00m 00s - Coupon code: cramtick70

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

Questions 4

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

Buy Now
Questions 5

Given:

const str = ' Salesforce ' ;

Which two statements result in ' Sales ' ?

Options:

A.

str.substring(0, 5);

B.

str.substring(1, 5);

C.

str.substr(0, 5);

D.

str.substr(1, 5);

Buy Now
Questions 6

Given the code:

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

09 function Console16bit(name) {

10 GameConsole.call(this, name);

11 }

12

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

14

15 // insert code here

16 console.log( ' ${this.name} is loading a cartridge game: ${gamename}.... ' );

17 }

18

19 const console16bit = new Console16bit( ' SNEGeneziz ' );

20 console16bit.load( ' Super Monic 3x Force ' );

What should a developer insert at line 15?

Options:

A.

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

B.

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

C.

Console16bit.prototype.load(gamename) {

D.

Console16bit.prototype.load = function(gamename) {

Buy Now
Questions 7

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 8

A developer executes:

document.cookie;

document.cookie = ' key=John Smith ' ;

What is the behavior?

Options:

A.

Cookies are read and the key value is set, the remaining cookies are unaffected.

B.

Cookies are read, but the key value is not set because the value is not URL encoded.

C.

Cookies are not read because line 01 should be document.cookies, but the key value is set and all cookies are wiped.

D.

Cookies are read and the key value is set, and all cookies are wiped.

Buy Now
Questions 9

Refer to the code below:

01 < html lang= " en " >

02 < table onclick= " console.log( ' Table log ' ); " >

03 < tr id= " row1 " >

04 < td > Click me! < /td >

05 < /tr >

06 < /table >

07 < script >

08 function printMessage(event) {

09 console.log( ' Row log ' );

10 event.stopPropagation();

11 }

12

13 let elem = document.getElementById( ' row1 ' );

14 elem.addEventListener( ' click ' , printMessage, false);

15 < /script >

16 < /html >

Which code change should be done for the console to log the following when " Click me! " is clicked?

Row log

Table log

Options:

A.

Change line 14 to elem.addEventListener( ' click ' , printMessage, true);

B.

Remove lines 13 and 14

C.

Change line 10 to event.stopPropagation(false);

D.

Remove line 10

Buy Now
Questions 10

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

Buy Now
Questions 11

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 12

A developer wants to advocate for a mature, well-supported web framework/library instead of a new one (Minimalist.js).

Which two should be recommended?

Options:

A.

React

B.

Koa

C.

Vue

D.

Express

Buy Now
Questions 13

Original code:

01 let requestPromise = client.getRequest;

03 requestPromise().then((response) = > {

04 handleResponse(response);

05 });

The developer wants to gracefully handle errors from a Promise-based GET request.

Which code modification is correct?

Options:

A.

try/catch around requestPromise().then(...)

B.

(duplicate of A)

C.

Add .catch to the Promise chain

D.

Use finally handler for errors

Buy Now
Questions 14

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)

Buy Now
Questions 15

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 16

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 notstrict mode.

B.

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

C.

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

D.

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

Buy Now
Questions 17

Refer to the code below:

01 const myFunction = arr = > {

02 return arr.reduce((result, current) = > {

03 return result + current;

04 }, 10);

05 }

What is the output of this function when called with an empty array?

Options:

A.

Returns 0

B.

Throws an error

C.

Returns NaN

D.

Returns 5 ← (Text here appears to be a typo; correct value is 10, see explanation.)

Buy Now
Questions 18

Refer to the code below:

01 let total = 10;

02 const interval = setInterval(() = > {

03 total++;

04 clearInterval(interval);

05 total++;

06 }, 0);

07 total++;

08 console.log(total);

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

Options:

A.

11

B.

12

C.

10

D.

13

Buy Now
Questions 19

A developer is setting up a new Node.js server with a client library that is built using events and callbacks.

The library:

    Will establish a web socket connection and handle receipt of messages to the server.

    Will be imported with require, and made available with a variable called ws.

    The developer also wants to add error logging if a connection fails.

Given this information, which code segment shows the correct way to set up a client with two events that listen at execution time?

Options:

A.

ws.connect(() = > {

console.log( ' Connected to client ' );

}).catch((error) = > {

console.log( ' ERROR ' , error);

});

B.

ws.on( ' connect ' , () = > {

console.log( ' Connected to client ' );

});

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

console.log( ' ERROR ' , error);

});

C.

ws.on( ' connect ' , () = > {

console.log( ' Connected to client ' );

});

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

console.log( ' ERROR ' , error);

});

D.

try {

ws.connect(() = > {

console.log( ' Connected to client ' );

});

} catch(error) {

console.log( ' ERROR ' , error);

}

Buy Now
Questions 20

Refer to the code below:

01 const addBy = ?

02 const addByEight = addBy(8);

03 const sum = addByEight(50);

Which two functions can replace line 01 and return 58 to sum?

Options:

A.

const addBy = function(num1) {

return function(num2) {

return num1 + num2;

}

}

B.

const addBy = function(num1) {

return num1 * num2;

}

C.

const addBy = (num1) = > num1 + num2;

D.

(Corrected for typing errors)

const addBy = (num1) = > {

return function(num2) {

return num1 + num2;

}

}

Buy Now
Questions 21

Refer to the code below:

01 let first = ' Who ' ;

02 let second = ' What ' ;

03 try {

04 try {

05 throw new Error( ' Sad trombone ' );

06 } catch (err) {

07 first = ' Why ' ;

08 throw err;

09 } finally {

10 second = ' When ' ;

11 }

12 } catch (err) {

13 second = ' Where ' ;

14 }

What are the values for first and second once the code executes?

Options:

A.

first is Who and second is Where.

B.

first is Why and second is Where.

C.

first is Who and second is When.

D.

first is Why and second is When.

Buy Now
Questions 22

Universal Containers (UC) just launched a new landing page, but users complain that the website is slow. A developer found some functions 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.

01 console.time( ' Performance ' );

02

03 maybeAHeavyFunction();

04

05 thisCouldTakeTooLong();

06

07 orMaybeThisOne();

08

09 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.trace()

C.

console.timeStamp()

D.

console.getTime()

Buy Now
Questions 23

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 24

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 25

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 26

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 27

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.

Buy Now
Questions 28

const str = ' Salesforce ' ;

Which two statements result in the word " Sales " ?

Options:

A.

str.substring(0, 5);

B.

str.substr(s, 5);

C.

str.substring(0, 5);

D.

str.substr(0, 5);

Buy Now
Questions 29

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 30

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 31

Refer to the code below:

01 const server = require( ' server ' );

02

03 // Insert code here

A developer imports a library that creates a web server. The imported library uses events and callbacks to start the server.

Which code should be inserted at line 03 to set up an event and start the web server?

Options:

A.

server.on( ' connect ' , (port) = > { console.log( ' Listening on ' , port); });

B.

server.start();

C.

server((port) = > { console.log( ' Listening on ' , port); });

D.

server();

Buy Now
Questions 32

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 33

Refer to the code below:

01 function myFunction(reassign) {

02 let x = 1;

03 var y = 1;

04

05 if (reassign) {

06 let x = 2;

07 var y = 2;

08 console.log(x);

09 console.log(y);

10 }

11

12 console.log(x);

13 console.log(y);

14 }

What is displayed when myFunction(true) is called?

Options:

A.

2 2 2 2

B.

2 2 1 2

C.

2 2 1 1

D.

2 2 undefined undefined

Buy Now
Questions 34

A 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?

Options:

A.

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

B.

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

C.

Uses non-blocking functionality for performant request handling.

D.

Ensures stability with one major release every few years.

E.

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

Buy Now
Questions 35

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

Buy Now
Questions 36

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

Buy Now
Questions 37

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 38

Value of:

true + 3 + ' 100 ' + null

Options:

A.

" 4100null "

B.

104

C.

" 4100 "

D.

" 2200null "

Buy Now
Questions 39

Most accurate tests for:

const arr = Array(5).fill(0);

Options:

A.

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

B.

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

C.

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

D.

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

Buy Now
Questions 40

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 41

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 }

Buy Now
Questions 42

Refer to the following code:

01 class Ship {

02 constructor(size) {

03 this.size = size;

04 }

05 }

06

07 class FishingBoat extends Ship {

08 constructor(size, capacity){

09 //Missing code

10 this.capacity = capacity;

11 }

12 displayCapacity() {

13 console.log( ' The boat has a capacity of ${this.capacity} people. ' );

14 }

15 }

16

17 let myBoat = new FishingBoat( ' medium ' , 10);

18 myBoat.displayCapacity();

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

B.

ship.size = size;

C.

super.size = size;

D.

this.size = size;

Buy Now
Questions 43

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.

Buy Now
Questions 44

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
Exam Name: Salesforce Certified JavaScript Developer (JS-Dev-101)
Last Update: May 22, 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