Loading

Quipoin Menu

Learn • Practice • Grow

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

Q1.

To create a custom module that exports a single function, you would write:
A. exports = function() {};
B. export default function() {};
C. function = module.exports;
D. module.exports = function() {};
Direction: Choose the correct option

Q2.

How do you import a local module located at `./utils.js`?
A. require('./utils')
B. import from './utils'
C. require('utils')
D. import './utils'
Direction: Choose the correct option

Q3.

If you want to export multiple functions from a module, you should:
A. Use `export` keyword
B. Assign each to `module.exports`
C. Create a new object
D. Assign each to `exports.funcName`
Direction: Choose the correct option

Q4.

What happens if you use both `exports` and `module.exports` in the same module?
A. They are merged
B. `module.exports` overrides `exports`
C. `exports` overrides `module.exports`
D. An error is thrown
Direction: Choose the correct option

Q5.

In a module, where does Node.js look for modules required without a path (e.g., `require('fs')`)
A. NPM registry
B. Current directory
C. Core modules first, then `node_modules`
D. Global `node_modules`