node-module-system Flashcards

1
Q

What is a JavaScript module?

A

a way to organize and reuse code, to encapsulate specific functionality in a single unit, called a module, which can then be imported and used in other parts of your code.

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

What values are passed into a Node.js module’s local scope?

A

exports: This is an object that is used to export values and functionality from the module, making them available to other modules that import it.

require: This is a function that is used to import other modules and access their exports.

module: This is an object that represents the current module and provides information about it, such as its filename and the exports object.

__filename: This is a global variable that contains the absolute path of the current module’s file.

__dirname: This is a global variable that contains the absolute path of the directory that the current module is located in.

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

Give two examples of truly global variables in a Node.js program.

A

process … console

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