Skip to content
Open
Overdue by 1 year(s)
Due by January 13, 2024
Last updated Jan 8, 2016
50% complete

If you want the root of your module's export to be a function (such as a constructor) or if you want to export a complete object in one assignment instead of building it one property at a time, assign it to module.exports instead of exports.

Below, bar.js makes use of the square module, which exports a constructor:

You can also simply indent your code by four spaces:

function fancyAlert(arg) {

var square = require('./square.js');
var mySquare = square(2);
console.log('The area of my square is ' + mySquare.area());
}
function fancyAlert(arg) {
var square = require('./square.js');
var mySquare = square(2);
console.log('The area of my square is ' + mySquare.area());
}

List view