Docsity

JavaScript Developer Certification Practice Exam Q&A, Exams of Nursing

Toggle sidebar
bg1
Salesforce JavaScript Developer I Cert
Practice Exam Q/A
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. arr.sort();
B. arr.sort((a, b) => a - b);
C. arr.sort((a, b) => a < b);
D. arr.sort((a, b) => b - a); ✔ ANSWER:
B. arr.sort((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. arr.sort();
B. arr.sort((a, b) => a - b);
C. arr.reverse();
D. arr.sort((a, b) => b - a); ✔ ANSWER:
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19
pf1a
pf1b
pf1c
pf1d
pf1e
pf1f
pf20
pf21
pf22
pf23
pf24
pf25
pf26
pf27
pf28
pf29
pf2a
pf2b
pf2c
pf2d
pf2e
pf2f
pf30
pf31
pf32
pf33
pf34
pf35

Partial preview of the text

Download JavaScript Developer Certification Practice Exam Q&A and more Exams Nursing in PDF only on Docsity!

Salesforce JavaScript Developer I Cert

Practice Exam Q/A

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. arr.sort(); B. arr.sort((a, b) => a - b); C. arr.sort((a, b) => a < b); D. arr.sort((a, b) => b - a); ✔ANSWER: B. arr.sort((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. arr.sort(); B. arr.sort((a, b) => a - b); C. arr.reverse(); D. arr.sort((a, b) => b - a); ✔ANSWER:

C. arr.reverse(); 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";

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/DatePrettyPrint.js'; printDate(); B. import printDate from '/path/DatePrettyPrint.js'; printDate(); C. import DatePrettyPrint from '/path/DatePrettyPrint.js'; DatePrettyPrint.printDate(); D. import printDate from '/path/DatePrettyPrint.js'; DatePrettyPrint.printDate(); ✔ANSWER: B. import printDate from '/path/DatePrettyPrint.js'; 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 ,