Salesforce JavaScript-Developer-I - Salesforce Certified JavaScript Developer (JS-Dev-101)
Total 147 questions
Corrected code:
let a = " * " ;
let b = " ** " ;
// x = 3;
console.log(a);
What is displayed when the code executes?
A developer copied a JavaScript object:
01 function Person() {
02 this.firstName = " John " ;
03 this.lastName = " Doe " ;
04 this.name = () = > `${this.firstName},${this.lastName}`;
05 }
06
07 const john = new Person();
08 const dan = Object.assign({}, john);
09 dan.firstName = ' Dan ' ;
How does the developer access dan ' s firstName, lastName?
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?
Function to test:
01 const sum3 = (arr) = > {
02 if (!arr.length) return 0;
03 if (arr.length === 1) return arr[0];
04 if (arr.length === 2) return arr[0] + arr[1] ;
05 return arr[0] + arr[1] + arr[2];
06 };
Which two assert statements are valid tests for this function?
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?
Given the code:
const copy = JSON.stringify([new String( ' false ' ), new Boolean(false), undefined]);
What is the value of copy?
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?
A developer writes the code below to return a message to a user attempting to register a new username. If the username is available, a variable named msg is declared and assigned a value on line 03.
function getAvailabilityMessage(item) {
if (getAvailability(item)) {
var msg = " Username available " ;
return msg;
}
}
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?
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?
