Loading

Quipoin Menu

Learn • Practice • Grow

node-js / CommonJS Modules
mcq
Direction: Choose the correct option

Q1.

What module system does Node.js use by default?
A. ES Modules
B. AMD
C. UMD
D. CommonJS
Direction: Choose the correct option

Q2.

How do you import a module in CommonJS?
A. include('module')
B. require('module')
C. module.import('module')
D. import module from 'module'
Direction: Choose the correct option

Q3.

How do you export a function from a module in CommonJS?
A. module.exports = function
B. export default function
C. Both B and C
D. exports.function = function
Direction: Choose the correct option

Q4.

What is the difference between `exports` and `module.exports`?
A. `module.exports` is for functions only
B. `exports` is a reference to `module.exports` initially, but reassigning `exports` breaks it
C. `exports` is global
D. They are the same object
Direction: Choose the correct option

Q5.

What does `require('./module')` return?
A. The value of `module.exports` from that file
B. The file contents as a string
C. A buffer
D. An error