From 889986a3824714d060baf489bd77521a0f79d74d Mon Sep 17 00:00:00 2001 From: Cameron Moorehead Date: Mon, 27 Nov 2017 18:01:56 -0800 Subject: [PATCH] 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: https://github.com/nodejs/node/pull/17364 Reviewed-By: Anna Henningsen Reviewed-By: Jon Moss Reviewed-By: Colin Ihrig Reviewed-By: Timothy Gu --- doc/api/modules.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/doc/api/modules.md b/doc/api/modules.md index 2c5291214af6ac..7b1be55c93f6e8 100644 --- a/doc/api/modules.md +++ b/doc/api/modules.md @@ -41,9 +41,9 @@ or object). Below, `bar.js` makes use of the `square` module, which exports a constructor: ```js -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`: