JAVASCRIPT-DEVELOPER-I practice question 6 of 30
A developer has an ErrorHandler module that contains multiple functions. What kind of export should be leveraged so that multiple functions can be used?
Full set: 219 questionsDomain Objects, Functions, and Classes
In JavaScript ES6 modules, which are fundamental to Lightning Web Components, there are two types of exports: named and default. A module can have multiple named exports but only one default export. To make multiple functions from a single module (like ErrorHandler) available for other modules to import and use, named exports must be used. Each function is exported using the export keyword followed by its declaration, and imported using its specific name within curly braces {}.
A. all: export all is not a valid JavaScript syntax for exporting multiple functions from the current module. The export from 'module' syntax is for re-exporting from another module.
C. multi: "multi" is not a recognized keyword or type of export in the JavaScript ES6 module system.
D. default: A module can only have one default export. This is typically used for the main or primary value of a module, not for exporting multiple, distinct functions.
1. Salesforce Lightning Web Components Developer Guide:
Section: Share JavaScript Code
Content: The documentation explicitly demonstrates using named export statements to share multiple utility functions from a JavaScript file. It states, "To import the functions, use the import statement with the function names in curly braces." This directly supports the use of named exports for multiple functions.
2. MDN Web Docs (Mozilla):
Page: export statement
Content: This is a canonical resource for the JavaScript language. It clearly defines and provides syntax for "Named exports" and "Default export." The documentation specifies, "Named exports are useful to export several values. During the import, one will be able to use the same name to refer to the corresponding value." This confirms that exporting "multiple functions" requires named exports.
3. ExploringJS by Dr. Axel Rauschmayer (Academic Resource):
Chapter: 17. Modules
Section: 17.3.1 Named exports (several per module)
Content: This text, often used in academic settings, explains, "You can have multiple named exports per module. A named export is created by prefixing a declaration with the keyword export." This academic source validates that the standard mechanism for exporting several items is the named export.
Keep practicing
Take the free JAVASCRIPT-DEVELOPER-I practice test
Ten exam-style questions with answers and explanations, plus the exam facts and study guides.
More questions
Other JAVASCRIPT-DEVELOPER-I practice questions
- Question 1A developer wants to set up a secure web server withNode.js. The developer creates a dire…
- Question 3Given two expressions var1 and var2. What are two valid ways to return the logical AND of…
- Question 4A test has a dependency on database.query. During the test the dependency is replaced wit…
- Question 5Refer to code below: function Person() { this.firstName = ’John’; } Person.prototype ={ J…
- Question 8Refer to the code below: const event = new CustomEvent( //Missing Code ); obj.dispatchEve…
- Question 9Refer to the code below: Let foodMenu1 = [‘pizza’, ‘burger’, ‘French fries’]; Let finalMe…
