From 96c9f1dd88234602ebc83f9a7e21510f15b8a087 Mon Sep 17 00:00:00 2001 From: Cameron Moorehead Date: Mon, 27 Nov 2017 18:01:56 -0800 Subject: [PATCH 1/3] 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. --- doc/api/modules.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/api/modules.md b/doc/api/modules.md index f9f311d241ce92..3af7eb500f94a2 100644 --- a/doc/api/modules.md +++ b/doc/api/modules.md @@ -44,7 +44,7 @@ Below, `bar.js` makes use of the `square` module, which exports a constructor: ```js const square = require('./square.js'); -const mySquare = square(2); +const mySquare = new square(2); console.log(`The area of my square is ${mySquare.area()}`); ``` From acc507f73da8f1306af144b4a44c89ea424c9f1f Mon Sep 17 00:00:00 2001 From: Cameron Moorehead Date: Mon, 27 Nov 2017 19:53:58 -0800 Subject: [PATCH 2/3] doc: square constructor name capitalized to Square --- 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 3af7eb500f94a2..39d6b994d3042d 100644 --- a/doc/api/modules.md +++ b/doc/api/modules.md @@ -43,9 +43,9 @@ or object). Below, `bar.js` makes use of the `square` module, which exports a constructor: ```js -const square = require('./square.js'); -const mySquare = new 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 my Square is ${mySquare.area()}`); ``` The `square` module is defined in `square.js`: From fb9af62a74f405c291dfea13190450f3f458e175 Mon Sep 17 00:00:00 2001 From: Cameron Moorehead Date: Mon, 27 Nov 2017 19:56:26 -0800 Subject: [PATCH 3/3] doc: my Square to mySquare --- doc/api/modules.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/api/modules.md b/doc/api/modules.md index 39d6b994d3042d..2888e684b23f11 100644 --- a/doc/api/modules.md +++ b/doc/api/modules.md @@ -45,7 +45,7 @@ Below, `bar.js` makes use of the `square` module, which exports a constructor: ```js const Square = require('./square.js'); const mySquare = new Square(2); -console.log(`The area of my Square is ${mySquare.area()}`); +console.log(`The area of mySquare is ${mySquare.area()}`); ``` The `square` module is defined in `square.js`: