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

Pass the Salesforce Salesforce Developer JavaScript-Developer-I Questions and answers with CertsForce

Viewing page 3 out of 5 pages
Viewing questions 21-30 out of questions
Questions # 21:

Refer to the following object:

const dog = {

firstName: ' Beau ' ,

lastName: ' Boo ' ,

get fullName() {

return this.firstName + ' ' + this.lastName;

}

};

How can a developer access the fullName property for dog?

Options:

A.

dog.fullName


B.

dog.fullName()


C.

dog.get.fullName


D.

dog.function.fullName()


Expert Solution
Questions # 22:

Refer to the code below:

01 let timedFunction = () = > {

02 console.log( ' Timer called. ' );

03 };

04

05 let timerId = setInterval(timedFunction, 1000);

Which statement allows a developer to cancel the scheduled timed function?

Options:

A.

clearInterval(timerId);


B.

removeInterval(timerId);


C.

removeInterval(timedFunction);


D.

clearInterval(timedFunction);


Expert Solution
Questions # 23:

A developer wants to use a try...catch statement to catch any error that countSheep() may throw and pass it to a handleError() function.

What is the correct implementation of the try...catch?

Options:

A.

setTimeout(function() {

try {

countSheep();

} catch (e) {

handleError(e);

}

}, 1000);


B.

try {

countSheep();

} finally {

handleError(e);

}


C.

try {

countSheep();

} handleError (e){

catch(e);

}


D.

try {

setTimeout(function() {

countSheep();

}, 1000);

} catch (e) {

handleError(e);

}


Expert Solution
Questions # 24:

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


Expert Solution
Questions # 25:

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


Expert Solution
Questions # 26:

Refer to the code below (assuming Promise.race is intended):

let cat3 = new Promise(resolve = >

setTimeout(resolve, 3000, " Cat 3 completes " )

);

Promise.race([cat1, cat2, cat3])

.then(value = > {

let result = `${value} the race.`;

})

.catch(err = > {

console.log( " Race is cancelled: " , err);

});

(Assuming cat1 and cat2 are similar to earlier examples: cat2 resolves fastest.)

What is the value of result when Promise.race executes?

Options:

A.

Car 2 completed the race.


B.

Car 1 crashed on the race.


C.

Race is cancelled.


D.

Car 3 completed the race.


Expert Solution
Questions # 27:

Refer to the following code:

01 let obj = {

02 foo: 1,

03 bar: 2

04 }

05 let output = []

06

07 for (let something of obj) {

08 output.push(something);

09 }

10

11 console.log(output);

What is the value of output on line 11?

Options:

A.

An error will occur due to the incorrect usage of the for_of statement on line 07.


B.

[1, 2]


C.

[ " foo " , " bar " ]


D.

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


Expert Solution
Questions # 28:

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.


Expert Solution
Questions # 29:

Correct implementation of try...catch for countsDeep():

Options:

A.

try {

countsDeep();

} handleError (e){

catch(e);

}


B.

setTimeout(function() {

try {

countsDeep();

} catch (e) {

handleError(e);

}

}, 1000);


C.

try {

setTimeout(function() {

countsDeep();

}, 1000);

} catch (e) {

handleError(e);

}


D.

try {

setTimeout(function() {

countsDeep();

}, 1000);

} catch (e) {

handleError(e);

}


Expert Solution
Questions # 30:

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 " ]


Expert Solution
Viewing page 3 out of 5 pages
Viewing questions 21-30 out of questions