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
0 issues of 2 selected
- Status: Open (in progress).GistIcon/angularnumber 38#38 In GistIcon/angular;
- Status: Open (in progress).GistIcon/angularnumber 37#37 In GistIcon/angular;