Salesforce JavaScript Developer I Cert Practice Exam {Answered} with additional info.
Salesforce JavaScript Developer I Cert Practice Exam {Answered} Which two syntax examples correctly initialize a value to the variable strLang? A. let strLang = 'javascript'; B. const strLang = 'java' + 'script'; C. let strLang = javascript; D. str strLang = 'javascript'; - ANSWER: A. let strLang = 'javascript'; B. const strLang = 'java' + 'script'; Additional Info: Note that C doesn't have a value that has single quotes around the word 'javascript' and for D, 'str' is not a proper identifier Which statement sorts the following number array so it is in ascending order? const arr = [7, 3, 400, 10]; A. (); B. ((a, b) = a - b); C. ((a, b) = a b); D. ((a, b) = b - a); - ANSWER: B. ((a, b) = a - b); Additional Info: A. The sort() function sorts values as strings, which will sort this as [10, 3, 400, 7]. C. The compare function expects a positive, negative, or 0 to be returned. D. The compare function will actually reverse the order of the numbers. Which statement sorts the following string array so it is in descending order? const arr = ["Banana", "Orange", "Apple", "Mango"]; A. (); B. ((a, b) = a - b); C. se(); D. ((a, b) = b - a); - ANSWER: C. se(); Additional Info: A. The sort() function sorts values as strings in ASCENDING order: ["Apple", "Banana", "Mango", "Orange"]; B,D. Expect a number array. What are the different data types used in JavaScript? - ANSWER: There are 8 basic data types in JavaScript: 1. Number for numbers of any kind: integer or floating-point, integers are limited by ±((2^53)-1). 2. BigInt is for integer numbers of arbitrary length. 3. String for strings. A string may have zero or more characters, there's no separate single-character type. 4. Boolean for true/false. 5. NULL for unknown values - a standalone type that has a single value null. Note, typeof null returns "object" even though it is NOT and object. 6. Undefined for unassigned values - a standalone type that has a single value undefined. 7. Object for more complex data structures. 8. Symbol for unique identifiers. Which collections of data are ordered by a key? - ANSWER: Map and set objects. What is the proper syntax for adding placeholders in template literals? - ANSWER: Use a dollar sign followed by curly brackets: ${expression}. Additional Info: let name = "John"; // embed a variable alert( `Hello, ${name}!` ); // Hello, John! // embed an expression alert( `the result is ${1 + 2}` ); // the result is 3 Note this only works if you use backticks, `, and not single(') or double(") quotes otherwise the results will be shown as literal, ie: Hello, ${name}! How do you instantiate a value as a BigInt? A. Nothing, JavaScript will automatically cast a number to a BigInt if the value is greater than ((2^53) - 1) B. const bigInt = BigI(7890); C. const bigInt = 7890n; D. const bigInt = BigI('7890'); - ANSWER: C. const bigInt = 7890n; Additional Info: BigInt does NOT work in IE. Given the following Animal constructor: function Animal(size, age) { = size; = age; Talk = false; } Which method creates a new instance of the object? A. Oe('Animal'); B. new Animal('large', 10); C. Otype(Animal); D. O(Animal); - ANSWER: B. new Animal('large', 10); Additional Info: A. The create method needs the object name without quotes. C. This is an incorrect way to use a prototype. Prototypes are used to add methods to existing constructors. D. This is not the correct way to use the new keyword. It is not a method. A developer wants to use a module called DatePrettyPrint. This module exports one default function called printDate(). How can a developer import and use the printDate() function? A. import printDate() from '/path/DatePrettyP'; printDate(); B. import printDate from '/path/DatePrettyP'; printDate(); C. import DatePrettyPrint from '/path/DatePrettyP'; DatePrettyPDate(); D. import printDate from '/path/DatePrettyP'; DatePrettyPDate(); - ANSWER: B. import printDate from '/path/DatePrettyP'; printDate(); Additional Info: Once imported by name, you must call the imported method directly by name. You must call the methods directly or use the * to import all methods. When using the `const` identifier to create an instance of an object, are the properties changeable? - ANSWER: Yes. An object declared as `const` can be modified. The `const` fixes the value of the object, but NOT its contents. A developer is not able to use a variable outside a function that is defined inside a function. What could be causing this? - ANSWER: Variables defined INSIDE a function cannot be accessed from anywhere OUTSIDE the function, because the variable is defined only in the scope of the function. If an application manipulates the browser history using the History API, which event should a developer use to detect when the browser's native back or forward button is clicked? A. popstate B. navigate C. pushstate D. change - ANSWER: A. Popstate, A popstate event is dispatched to the window each time the active history entry changes between two history entries for the same document. Additional Info: The navigate() method loads a specified URL. The pushstate() method pushes the given data onto the session history stack with the specified title. The change event is fired for changes to input, select , and textarea elements. Given two nested divs and the code below which d kicks off: the window loads and fires the following event = { Selector('.outerDiv') .addEventListener('click', displayOuterMessage, true); Selector('.innerDiv') .addEventListener('click', displayInnerMessage, true); }; What order will the event listeners be called when the innerDiv is clicked? A. displayInnerMessage, displayOuterMessage B. displayInnerMessage only C. displayOuterMessage only D. displayOuterMessage, displayInnerMessage - ANSWER: D. displayOuterMessage, displayInnerMessage Additional Info: Events in the target phase will trigger all listeners on an element in the order they were registered. Events are fired inside the browser window and tend to attach to specific items residing in the browser. What are some of these items? - ANSWER: A single element, set of elements, the HTML document loaded in the current tab, or the entire browser window. What are some of the basic DOM data types? - ANSWER: Document, node, element, nodeList, attribute, and namedNodemap. What will the output be in the console for the following: (x); var x = 10; - ANSWER: undefined Additional Info: var is susceptible to hoisting. What will the output be in the console for the following: (x); let x = 10; - ANSWER: ReferenceError Additional Info: let and const do not do hoisting. What is the difference between == vs ===? - ANSWER: == compares the direct value while === compares the direct value and type. Additional Info: 10 == '10' // true 10 === '10' // false What will the output be in the console for the following: const myDt = new Date(); (myDt + 10); - ANSWER: Today's date, plus 10 days. Continue........................................................
Document information
- Uploaded on
- November 10, 2022
- Number of pages
- 45
- Written in
- 2022/2023
- Type
- Exam (elaborations)
- Contains
- Questions & answers