Skip to content

Commit

Permalink
doc: 'constructor' implies use of new keyword
Browse files Browse the repository at this point in the history
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 <[email protected]>
Reviewed-By: Jon Moss <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: Timothy Gu <[email protected]>
  • Loading branch information
CameronMoorehead authored and gibfahn committed Dec 20, 2017
1 parent 94d9f20 commit 889986a
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions doc/api/modules.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`:
Expand Down

0 comments on commit 889986a

Please sign in to comment.