Loading

Quipoin Menu

Learn • Practice • Grow

node-js / ES Modules in Node.js
mcq
Direction: Choose the correct option

Q1.

What file extension is commonly used for ES modules in Node.js?
A. .es6
B. .js
C. .module
D. .mjs
Direction: Choose the correct option

Q2.

How do you import a module using ES module syntax?
A. import * as x from 'x'
B. Both B and C
C. import x from 'x'
D. const x = require('x')
Direction: Choose the correct option

Q3.

How do you export a function as default in an ES module?
A. export default function() {};
B. exports.default = function() {};
C. export = function() {};
D. module.exports = function() {};
Direction: Choose the correct option

Q4.

To use ES modules in a `.js` file, what must be set in `package.json`?
A. `esm: true`
B. `type: commonjs`
C. `type: module`
D. `module: es6`
Direction: Choose the correct option

Q5.

Can you use `require()` inside an ES module?
A. No, by default; you need to use `import`
B. Only for core modules
C. Only with `--experimental-require`
D. Yes, always