Skip to content

Commit 1eff647

Browse files
CameronMooreheadMylesBorins
authored andcommitted
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 <[email protected]> Reviewed-By: Jon Moss <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Timothy Gu <[email protected]>
1 parent fb3ea4c commit 1eff647

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

doc/api/modules.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,9 @@ or object).
4141
Below, `bar.js` makes use of the `square` module, which exports a constructor:
4242

4343
```js
44-
const square = require('./square.js');
45-
const mySquare = square(2);
46-
console.log(`The area of my square is ${mySquare.area()}`);
44+
const Square = require('./square.js');
45+
const mySquare = new Square(2);
46+
console.log(`The area of mySquare is ${mySquare.area()}`);
4747
```
4848

4949
The `square` module is defined in `square.js`:

0 commit comments

Comments
 (0)