Modules and Imports Flashcards

(8 cards)

1
Q

Which keyword ensures that a JavaScript module’s internal variables/functions cannot be modified from outside the module?

A

None, as modules inherently provide this encapsulation

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

In ES6 module syntax, how would you import only specific functions or variables from a module?

A

import { functionName } from ‘module-name’;

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

If a module exports multiple items, and one as default, how would you import the default export and a named export simultaneously?

A

import defaultExport, { namedExport } from ‘module-name’;

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What is the purpose of “default” in ES6 module exports?

A

To specify the primary export of a module

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Which keyword is used to export a module in ES6 JavaScript?

A

export

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

If a JavaScript module has a default export, how would you import it?

A

import defaultExport from ‘module-name’;

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Which of the following is a way to import everything from a module in ES6?

A

import * as aliasName from ‘module-name’;

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

If you see the import … from … syntax in a JavaScript file, what type of module system is it most likely using

A

ES6 Modules

How well did you know this?
1
Not at all
2
3
4
5
Perfectly