node-require-Q&A Flashcards

1
Q

What is the purpose of module.exports in a Node.js module?

A

The main purpose of module. exports is to achieve modular programming. Modular programming refers to separating the functionality of a program into independent, interchangeable modules, such that each contains everything necessary to execute only one aspect of the desired functionality.

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

How do you import functionality into a Node.js module from another Node.js module?

A
const add = require('./add');
assign the require method of your file to a variable.
'./add' = add.js
How well did you know this?
1
Not at all
2
3
4
5
Perfectly