SALESFORCE JAVASCRIPT
DEVELOPER 1 EXAM QUESTIONS
AND ANSWERS
A developer needs to pass an array as an argument, the current variable looks like an
array but is not one. What can be used to convert this variable into an array? - Correct
Answers -let arrayVar = Array.from(myVar);
const array1 = [1, 2, 3, 4];
const reducer = (accumulator, currentValue) => accumulator + currentValue;
console.log(array1.reduce(reducer)); - Correct Answers -10
Name two methods used to access Coordinated Universal Time, method converts a
date to a string. - Correct Answers -toISOString();
toUTCString();
Destructing Assignment Syntax
const hero = { name: 'Batman', realName: 'Bruce Wayne' };
const {_____________________ } = hero;
name; // => 'Batman', realName;
realName; // => 'Bruce Wayne' - Correct Answers -name, realName
Combining two arrays:
const cars = ["Saab", "Volvo", "BMW"];
var food = ["pizza", "tacos", "burgers"]; - Correct Answers -["Saab", "Volvo",
"BMW", ...food];
What would this return?
let num;
if(num == '' || num == null) {
num = true;
}
return num; - Correct Answers -true
let fake;
console.log((fake == 0)); //false
console.log((fake == null)) // true
, What would this return?
let count = null;
if(count == undefined && count== null) {
count = true;
}
return count; - Correct Answers -true
So:
undefined == null
What would this return?
let count = null;
if(count == "" && count== null) {
count = true;
}
return count; - Correct Answers -null
let fruit = [{type: 'Apple', price: 1.99, quantity: 3}, {type: 'Pear', price: 2.59, quantity: 2} ];
const cost = fruit.reduce((accumulator, currentValue) => {return(accumulator +
currentValue.price *currentValue.quantity)}, 0); - Correct Answers -11.15 (correct total)
What is the symbol data type? - Correct Answers -Symbol is a built-in object whose
constructor returns a symbol primitive — also called a Symbol value or just a Symbol —
that's guaranteed to be unique. Symbols are often used to add unique property keys to
an object that won't collide with keys any other code might add to the object, and which
are hidden from any mechanisms other code will typically use to access the object. That
enables a form of weak encapsulation, or a weak form of information hiding.
Every Symbol() call is guaranteed to return a unique Symbol. Every Symbol.for("key")
call will always return the same Symbol for a given value of "key". When
Symbol.for("key") is called, if a Symbol with the given key can be found in the global
Symbol registry, that Symbol is returned. Otherwise, a new Symbol is created, added to
the global Symbol registry under the given key, and returned.
In JS, null == undefined - Correct Answers -true
In JS, 0 == undefined - Correct Answers -false
In JS, 0 == false - Correct Answers -true
What is wrong with this code?
class Car {
constructor(brand) {
this.carname = brand;
}
DEVELOPER 1 EXAM QUESTIONS
AND ANSWERS
A developer needs to pass an array as an argument, the current variable looks like an
array but is not one. What can be used to convert this variable into an array? - Correct
Answers -let arrayVar = Array.from(myVar);
const array1 = [1, 2, 3, 4];
const reducer = (accumulator, currentValue) => accumulator + currentValue;
console.log(array1.reduce(reducer)); - Correct Answers -10
Name two methods used to access Coordinated Universal Time, method converts a
date to a string. - Correct Answers -toISOString();
toUTCString();
Destructing Assignment Syntax
const hero = { name: 'Batman', realName: 'Bruce Wayne' };
const {_____________________ } = hero;
name; // => 'Batman', realName;
realName; // => 'Bruce Wayne' - Correct Answers -name, realName
Combining two arrays:
const cars = ["Saab", "Volvo", "BMW"];
var food = ["pizza", "tacos", "burgers"]; - Correct Answers -["Saab", "Volvo",
"BMW", ...food];
What would this return?
let num;
if(num == '' || num == null) {
num = true;
}
return num; - Correct Answers -true
let fake;
console.log((fake == 0)); //false
console.log((fake == null)) // true
, What would this return?
let count = null;
if(count == undefined && count== null) {
count = true;
}
return count; - Correct Answers -true
So:
undefined == null
What would this return?
let count = null;
if(count == "" && count== null) {
count = true;
}
return count; - Correct Answers -null
let fruit = [{type: 'Apple', price: 1.99, quantity: 3}, {type: 'Pear', price: 2.59, quantity: 2} ];
const cost = fruit.reduce((accumulator, currentValue) => {return(accumulator +
currentValue.price *currentValue.quantity)}, 0); - Correct Answers -11.15 (correct total)
What is the symbol data type? - Correct Answers -Symbol is a built-in object whose
constructor returns a symbol primitive — also called a Symbol value or just a Symbol —
that's guaranteed to be unique. Symbols are often used to add unique property keys to
an object that won't collide with keys any other code might add to the object, and which
are hidden from any mechanisms other code will typically use to access the object. That
enables a form of weak encapsulation, or a weak form of information hiding.
Every Symbol() call is guaranteed to return a unique Symbol. Every Symbol.for("key")
call will always return the same Symbol for a given value of "key". When
Symbol.for("key") is called, if a Symbol with the given key can be found in the global
Symbol registry, that Symbol is returned. Otherwise, a new Symbol is created, added to
the global Symbol registry under the given key, and returned.
In JS, null == undefined - Correct Answers -true
In JS, 0 == undefined - Correct Answers -false
In JS, 0 == false - Correct Answers -true
What is wrong with this code?
class Car {
constructor(brand) {
this.carname = brand;
}