Browse files

doc: 'constructor' implies use of new keyword

The square module is described as exporting a constructor,
which would mean it would need to be invoked with the
new keyword in bar.js after requiring it. Otherwise it's
technically a factory function, not a constructor.

PR-URL: #17364
Reviewed-By: Anna Henningsen <>
Reviewed-By: Jon Moss <>
Reviewed-By: Colin Ihrig <>
Reviewed-By: Timothy Gu <>
  • Loading branch information...
CameronMoorehead authored and gibfahn committed Nov 28, 2017
1 parent 23edd08 commit f53b4df00ef0983e24bc65276cbd16266daf62aa
Showing with 3 additions and 3 deletions.
  1. +3 −3 doc/api/
@@ -43,9 +43,9 @@ instead of `exports`.
Below, `bar.js` makes use of the `square` module, which exports a constructor:
const square = require('./square.js');
const mySquare = square(2);
console.log(`The area of my square is ${mySquare.area()}`);
const Square = require('./square.js');
const mySquare = new Square(2);
console.log(`The area of mySquare is ${mySquare.area()}`);
The `square` module is defined in `square.js`:

0 comments on commit f53b4df

Please sign in to comment.