Summer Sale Limited Time 75% Discount Offer - Ends in 0d 00h 00m 00s - Coupon code = simple75
Pass the Salesforce Developer JavaScript-Developer-I Questions and answers with Dumpstech
Refer to the following code (correcting the missing template literal backticks):
let codeName = ' Bond ' ;
let sampleText = `The name is ${codeName}, Jim ${codeName}`;
A developer is trying to determine if a certain substring is part of a string.
Which three code statements return true?
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?
Refer to the code snippet:
01 function getAvailableilityMessage(item) {
02 if (getAvailableility(item)) {
03 var msg = " Username available " ;
04 }
05 return msg;
06 }
What is the return value of msg when getAvailableilityMessage( " newUserName " ) is executed and getAvailableility( " newUserName " ) returns false?
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 developer wants to advocate for a mature, well-supported web framework/library instead of a new one (Minimalist.js).
Which two should be recommended?
A class was written to represent regular items and sale items. Code:
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; }
08 console.log(regItem.description());
09 console.log(saleItem.description());
What is the output?
static delay = async delay = > {
return new Promise(resolve = > {
setTimeout(resolve, delay);
});
};
static asyncCall = async () = > {
await delay(1000);
console.log(1);
};
console.log(2);
asyncCall();
console.log(3);
Assume delay and asyncCall are in scope as functions.
What is logged to the console?
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?
Refer to the code below:
01 new Promise((resolve, reject) = > {
02 const fraction = Math.random();
03 if (fraction > 0.5) reject( ' fraction > 0.5, ' + fraction);
04 resolve(fraction);
05 })
06 .then(() = > console.log( ' resolved ' ))
07 .catch((error) = > console.error(error))
08 .finally(() = > console.log( ' when am I called? ' ));
When does Promise.finally on line 08 get called?
Refer to the code below (corrected to use a template literal on line 08):
01 let car1 = new Promise((_, reject) = >
02 setTimeout(reject, 2000, " Car 1 crashed in " )
03 );
04 let car2 = new Promise(resolve = >
05 setTimeout(resolve, 1500, " Car 2 completed " )
06 );
07 let car3 = new Promise(resolve = >
08 setTimeout(resolve, 3000, " Car 3 completed " )
09 );
10
11 Promise.race([car1, car2, car3])
12 .then(value = > {
13 let result = `${value} the race.`;
14 })
15 .catch(err = > {
16 console.log( " Race is cancelled. " , err);
17 });
What is the value of result when Promise.race executes?