Docsity
Docsity

Prepare for your exams
Prepare for your exams

Study with the several resources on Docsity


Earn points to download
Earn points to download

Earn points by helping other students or get them with a premium plan


Guidelines and tips
Guidelines and tips

Salesforce JavaScript Developer 1 Exam questions and answers exam test guide, Exams of Advanced Education

Salesforce JavaScript Developer 1 Exam questions and answers exam test guide

Typology: Exams

2023/2024

Available from 04/24/2024

carol-njeri
carol-njeri 🇺🇸

4.5

(2)

1.7K documents

1 / 20

Toggle sidebar

Related documents


Partial preview of the text

Download Salesforce JavaScript Developer 1 Exam questions and answers exam test guide and more Exams Advanced Education in PDF only on Docsity! Salesforce JavaScript Developer 1 Exam questions and answers exam test guide 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 ANSWER let arrayVar = Array.from(myVar); const array1 = [1, 2, 3, 4]; const reducer = (accumulator, currentValue) => accumulator + currentValue; console.log(array1.reduce(reducer)); - CORRECT ANSWER 10 Name two methods used to access Coordinated Universal Time, method converts a date to a string. - CORRECT ANSWER toISOString(); toUTCString(); Destructing Assignment Syntax const hero = { name: 'Batman', realName: 'Bruce Wayne' }; const {_____________________ } = hero; name; // => 'Batman', realName; realName; // => 'Bruce Wayne' - CORRECT ANSWER name, realName Combining two arrays: const cars = ["Saab", "Volvo", "BMW"]; var food = ["pizza", "tacos", "burgers"]; - CORRECT ANSWER ["Saab", "Volvo", "BMW", ...food]; What would this return? let num; if(num == '' || num == null) { num = true; } return num; - CORRECT ANSWER 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 ANSWER true So: undefined == null What would this return? let count = null; if(count == "" && count== null) { How could you import a method inside of a method called upon click? - CORRECT ANSWER import('./classDirectory/myClass.js').then(mod) => (mod.myNeededMethod()); Looking at the export and import declarations below, would this work between two different JS files? export { myFunction }; import m from './test'; - CORRECT ANSWER No, to rename the exported function default would need to be added export { myFunction as default }; True or False: If the values are defined the following would run and import the needed data? export { cube, foo, graph }; // other file import { cube, foo, graph } from './my-module.js'; - CORRECT ANSWER True, this would work True or False: A decorator function can extend class methods. - CORRECT ANSWER true - it can extend them _________ is actually nothing more than functions that return another function - CORRECT ANSWER Decorators What is the technical error with this declaration? const userData = () => { return '${this.name} - ${this.getAge()}';} - CORRECT ANSWER None - arrow functions can be used to bind the this keyword to an object in the scope that does not depend on how function was invoked Generator functions return a generator that can be used with .next allowing access to each item. This makes them idea repeated random number generation. - CORRECT ANSWER True True or false: Multiple decorators can be used on class methods and properties? - CORRECT ANSWER True What do each of the following do? Object.seal( ); Object.freeze( ); Object.preventExtensions( ); Object.create( ); - CORRECT ANSWER seal - can't add or delete , can change existing preventExtensions - can change properties or delete, cannot add new ones freeze - no changes create - new object JS decorator functions are passed three arguments, what are they? - CORRECT ANSWER target is the class that our object is an instance of. key is the property name, as a string, that we're applying the decorator to. descriptor is that property's descriptor object. Only one parameter is passed to a decorator when used to decorate a class, this parameter is the target object which is the class that is being decorated. - CORRECT ANSWER True Where would the following be used? export {getAges} from './customer/utility.js'; - CORRECT ANSWER In a passthrough module to allow other classes to easily access a number of different exported data, the from allows this to be done without writing an import line in the passthrough function itself, from like used during imports __________ is an Array-like object accessible inside functions that contains the values passed to a function. - CORRECT ANSWER arguments function func1(a, b, c) { console.log(arguments[0]); function handle(request, Closure $next , ...guards) { When the function is called with more than 3 arguments, all the arguments after $next will be added to the $guards array. Arguments object is an ________-like collections of values. The arguments object contains __________ values passed to the function. The arguments object is only available for _________________ functions. - CORRECT ANSWER array- like all the values non-arrow functions What will need to be added since the prototype is lost during object instantiation. myFruits.prototype = Object.create(Fruits.prototype); - CORRECT ANSWER The constructor, inheritance will set a structure but the constructor need to be added manually. Object.defineProperty(myFruit.prototype, 'constructor', {value: myFruits, enumerable: false, wriable: true }); True false: All items must be named when importing multiple from a module that names exports - CORRECT ANSWER True True or False: SetTimeout( ) is only called if the stack is empty, all other messages have been processed, and then it is called x milliseconds after that. - CORRECT ANSWER True unwatch(expr): Remove expression from watch list watchers: List all watchers and their values (automatically listed on each breakpoint) repl: Open debugger's repl for evaluation in debugging script's context exec expr: Execute an expression in debugging script's context Execution control# run: Run script (automatically runs on debugger's start) restart: Restart script kill: Kill script Various# scripts: List all loaded scripts version: Display V8's version - CORRECT ANSWER Node.js _____________: the class that represents an independent JavaScript execution thread. isMainThread : a boolean that is true if the code is not running inside of a Worker thread. parentPort : the MessagePort allowing communication with the parent thread If this thread was spawned as a Worker. - CORRECT ANSWER Worker The global property Infinity is a numeric value representing infinity. - CORRECT ANSWER infinity console.log('e: ' + (true + 3 + 'hi' + null)); (Exam Example) - CORRECT ANSWER 4hinull console.log('e: ' + (null + 'hi' + null)); // e: nullhinull console.log('e: ' + (null + 3 + 'hi' + null)); // e: 3hinull console.log('Hello, world!') function myIsNaN(num) { if(num == null){ return 0; } if(num2 == 3){ return 3; } } console.log('e: ' + myIsNaN(2)); console.log('e: ' + myIsNaN(2)(3)); - CORRECT ANSWER errors console.log('Hello, world!'); class Polygon { constructor() { this.name = 'yo'; } fred = function() { let x = 'y'; } } let p = new Polygon(); console.log('e: ' + p.fred); //(Possible Exam Example) - CORRECT ANSWER //Output: Hello, world! e: function() { let x = 'y'; } You can change properties of even constant declared objects console.log('Hello, world!') class Polygon { constructor() { this.name = 'yo'; } fred = function() { let x = 'y'; } } const p = new Polygon(); p.name = 'dude'; console.log('e: ' + p.name); (Exam Example) - CORRECT ANSWER True let obj = JSON.parse(JSON.stringify(myObj)); obj.name = 'fred'; document.getElementById("demo").innerHTML = obj.name; (Exam Example) - CORRECT ANSWER output: fred Node.js server with error handling: const p2 = (data) => new Promise((resolve, reject) => { setTimeout(() => resolve('${data}, P2 Resolved'), 1500, data); }); (Trailhead Question) Would the following correctly execute the code? async function getResult() { const data = await p1; return await p2(data); } getResult(); - CORRECT ANSWER Correct. Using await inside the function causes both to execute. const p1 = new Promise((resolve, reject) => { setTimeout(() => { resolve('P1 Resolved'); }, 1500); }); const p2 = (data) => new Promise((resolve, reject) => { setTimeout(() => resolve('${data}, P2 Resolved'), 1500, data); }); (Trailhead Question) Would the following correctly execute the code? A p1.then((data) => p2(data)).then(result => result); - CORRECT ANSWER Correct. The method promise.then() is used to associate further action with a promise that becomes settled. const p1 = new Promise((resolve, reject) => { setTimeout(() => { resolve('P1 Resolved'); }, 1500); }); const p2 = (data) => new Promise((resolve, reject) => { setTimeout(() => resolve('${data}, P2 Resolved'), 1500, data); }); Would the following correctly execute the code? p1().then(function() { p2().then(function(result) { return result; }); }); (Trailhead Question) - CORRECT ANSWER Incorrect. The syntax is wrong for calling p1 and p2. D as const p1 = new Promise((resolve, reject) => { setTimeout(() => { resolve('P1 Resolved'); }, 1500); }); const p2 = (data) => new Promise((resolve, reject) => { setTimeout(() => resolve('${data}, P2 Resolved'), 1500, data); }); (Trailhead Question) Would the following correctly execute the code? async function getResult() { const data = p1; const result = p2(data); } await getResult(); - CORRECT ANSWER Incorrect. The await is outside the function calling the data. When is await express used outside of the async expression? (Trailhead Question) - CORRECT ANSWER Never async function example { await... } The promise object returned by the new Promise constructor has internal properties. What are they? (Trailhead Question) - CORRECT ANSWER state — initially "pending", then changes to either "fulfilled" when resolve is called or "rejected" when reject is called. result — initially undefined, then changes to value when resolve(value) called or error when reject(error) is called. Here is the package.json for the bar.awesome module: {"name": "bar.awesome","version": "1.3.5","peerDependencies": { "baz": "5.x" }} A particular project has the package.json definition below. {"name": "UC Project Extra","version": "0.0.5","dependencies": { "bar.awesome": "1.3.5", "baz": "6.0.0" }} What happens when a developer executes npm install? (Trailhead Question) - CORRECT ANSWER There is a mismatch on the baz dependency that causes the warning. The bar versions are compatible, but the baz versions are not. bar does have a dependency on baz Refer to the code below: 01 const https = require('https'); 02 const server = https.createServer((req, res) => { 03 // code goes here 04 let reqData = JSON.parse(chunk); 05 console.log(reqData); }); res.end('OK'); }); server.listen(8000); Which code does the developer need to add to line 03 to receive incoming request data? A. req.on('data', (chunk) => { B. req.get((chunk) => {
Docsity logo



Copyright © 2024 Ladybird Srl - Via Leonardo da Vinci 16, 10126, Torino, Italy - VAT 10816460017 - All rights reserved