













Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
(Full Stack JavaScript) ES6 Modules Knowledge Assessment Q & S 2024(Full Stack JavaScript) ES6 Modules Knowledge Assessment Q & S 2024(Full Stack JavaScript) ES6 Modules Knowledge Assessment Q & S 2024(Full Stack JavaScript) ES6 Modules Knowledge Assessment Q & S 2024(Full Stack JavaScript) ES6 Modules Knowledge Assessment Q & S 2024
Typology: Exams
1 / 21
This page cannot be seen from the preview
Don't miss anything!














mathUtils.js? a) import { default as mathUtils } from './mathUtils.js'; b) import as mathUtils from './mathUtils.js'; c) import mathUtils from './mathUtils.js'; d) import { mathUtils } from './mathUtils.js';import mathUtils from './mathUtils.js';Rationale: Default exports are imported without curly braces.
Given a module geometry.js with the following exports, which statement correctly imports only the calculateArea function?
export function calculateArea(radius) { return Math.PI radius radius; } export function calculatePerimeter(radius) { return 2 Math.PI radius; } Which statement correctly re-exports all bindings from a module named utils.js? a) export default from './utils.js'; b) export from './utils.js'; c) import from './utils.js'; d) export { default as } from './utils.js';
export from './utils.js';Rationale: export is used to re-export all bindings from another module.
// module1.js export let counter = 1; // main.js import { counter } from './module1.js'; counter += 1; console.log(counter); a) 1 b) 2 c) NaN d) SyntaxError
Rationale: counter is a read-only binding when imported.
helpers.js and assigning them an alias helpers is ________.import as helpers from './helpers.js';Rationale: The syntax as alias is used for importing all named exports.
Rationale: Default exports are imported without curly braces using an alias.
Rationale: ES6 modules allow both named exports and a single default export within the same module.
Rationale: Imports are hoisted, meaning they are moved to the top of the file during compilation.
Rationale: Import statements cannot use dynamic expressions and must use string literals.
Rationale: Imported bindings are read-only views of the exports from the imported module.
Rationale: ES6 modules are implicitly in strict mode, which enforces stricter parsing and error handling.
Rationale: Dynamic import() is a function that can be used to import modules conditionally.
Rationale: ES6 modules are designed to encapsulate code, including functions and classes for modularity. Multiple Choice: Which statement about ES6 Modules is true? A) They have a global scope. B) They are always loaded asynchronously. C) They support both named and default exports. D) They cannot be imported into other modules.
Rationale: ES6 Modules allow developers to export multiple values from a single module using named exports and a single default export.
Fill-in-the-Blank: To import a default export from a module in ES6, you use the _ keyword.
Rationale: When importing a default export from an ES6 module, the import keyword is used followed by the module path and the name for the default export in curly braces. True/False: In ES6 Modules, all code is executed in global scope.
Rationale: ES6 Modules have their scope, which helps in avoiding pollution of the global scope by encapsulating code within modules. Multiple Choice: What is the purpose of the export default syntax in ES6 Modules? A) To export multiple named exports B) To define the default export for a module C) To prevent other modules from importing the current module
Multiple Choice: Which keyword is used to export a named export in an ES6 Module? A) import B) export C) require D) module
Rationale: The export keyword is used to export named exports from an ES6 Module, making them accessible to other modules. Fill-in-the-Blank: ES6 Modules use _ to control what is visible outside the module.
Rationale: In ES6 Modules, the exports object is used to define what parts of the module are accessible to other modules when imported. True/False:
ES6 Modules are supported in all major modern browsers without the need for transpilation.
Rationale: ES6 Modules are natively supported in modern browsers, allowing developers to use them without the need for transpilation tools like Babel. Multiple Choice: Which of the following is an advantage of using ES6 Modules? A) Reduced code maintainability B) Global namespace pollution C) Improved code organization D) Limited reusability
Rationale: ES6 Modules help in organizing code into smaller, reusable components, improving overall code organization and maintainability. Fill-in-the-Blank: Default exports in ES6 Modules can be imported using any name by using the _ keyword.
Rationale: ES6 Modules are loaded asynchronously, improving page load performance by fetching modules in parallel. Fill-in-the-Blank: The import as module syntax in ES6 Modules is used to _.
Rationale: The import as module syntax in ES6 Modules imports the entire module namespace, allowing access to all exports from the module. True/False: ES6 Modules can have both a named export and a default export in the same module.
Rationale: ES6 Modules allow for a combination of named exports and a default export within the same module, providing flexibility in exporting functionality.
Multiple Choice: Which statement correctly imports a single export named myExport from a module? A) import { myExport } from 'module'; B) import myExport from 'module'; C) import as myExport from 'module'; D) import 'module' as myExport;
Rationale: Option A uses the correct syntax for importing a named export from a module, which is enclosed in curly braces. True/False: The statement import as myModule from 'module'; imports all exports from 'module' as a single object named myModule.
Rationale: The import as syntax is used to import all named exports from a module as properties of a single object. Fill-in-the-Blank: To dynamically import a module, the _______ function can be used.
Rationale: The import() function allows for dynamic importing of modules, which can be useful for code splitting and lazy loading. Multiple Choice: What is the purpose of the default keyword in an export statement? A) To specify a fallback export
C) export default myFunc1, myFunc2; D) export let myLet = 'value';
Rationale: Option C is incorrect because the default keyword can only be used with a single value, not multiple values. True/False: The export keyword can be used inside a function to export local variables.
Rationale: The export keyword cannot be used inside functions; it is used at the top level of a module to export variables, functions, or classes. Fill-in-the-Blank: To import only a subset of exports from a module, use the syntax import { ____ } from 'module'; and replace the blanks with the desired exports.
Rationale: The curly braces are used to list the specific named exports that should be imported from the module. Multiple Choice: What does the export default statement do in a module? A) It exports the module's interface B) It exports a single value as the default export C) It sets the default values for all exports D) It exports all values as named exports
Rationale: The export default statement is used to define a single value that will be exported as the default from the module. True/False: A module can have multiple default exports.
Rationale: A module can only have one default export, which is the value that will be imported when the import statement does not use curly braces. Fill-in-the-Blank: The syntax to re-export all exports from a module is export from '____';.
Rationale: The export from 'module'; syntax is used to re-export all named exports from the specified module. Multiple Choice: How can you provide an alias for a default export when importing it? A) import { default as myAlias } from 'module'; B) import myAlias from 'module'; C) import as myAlias from 'module'; D) import myAlias, { default } from 'module';
Rationale: Option B is the correct way to import a default export and give it an alias; the other options are not valid syntax for this purpose.