Skip to main content
Journey Uncommon Logo
JourneyUncommon
easyNodeJSrequire and module.exportsSingle-choice MCQ

In a CommonJS module you write `module.exports = function () {}` and ALSO `exports.foo = 1`. What does an importer get from `require()`?

// lib.js module.exports = function greet() {}; exports.foo = 1; // main.js const lib = require('./lib'); console.log(typeof lib, lib.foo);