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

Salesforce JavaScript-Developer-I - Salesforce Certified JavaScript Developer (JS-Dev-101)

Page: 3 / 5
Total 147 questions

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?

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.

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?

A.

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

B.

server.start();

C.

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

D.

server();

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?

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

Refer to the following array:

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

Which two lines of code result in a second array, arr2, created such that arr2 is a reference to arr?

A.

let arr2 = arr.slice(0, 5);

B.

let arr2 = Array.from(arr);

C.

let arr2 = arr;

D.

let arr2 = arr.sort();

Which two console logs output NaN?

A.

console.log(10 / 0);

B.

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

C.

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

D.

console.log(10 / ' five ' );

Which statement allows a developer to update the browser navigation history without a page refresh?

A.

window.customHistory.pushState(newStateObject, ' ' , null);

B.

window.history.createState(newStateObject, ' ' );

C.

window.history.pushState(newStateObject, ' ' , null);

D.

window.history.updateState(newStateObject, ' ' );

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?

A.

constructor() {

B.

super(body, author, viewCount) {

C.

function Story(body, author, viewCount) {

D.

constructor(body, author, viewCount) {

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?

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 }

A developer publishes a new version of a package with new features that do not break backward compatibility. The previous version number was 1.1.3.

Following semantic versioning formats, what should the new package version number be?

A.

1.2.3

B.

1.1.4

C.

2.0.0

D.

1.2.0

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?

A.

4 2 1 5 3

B.

4 2 1 5 3

C.

1 4 2 3 5

D.

4 5 1 2 3