0
0
mirror of https://github.com/nodejs/node.git synced 2024-12-01 16:10:02 +01:00

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 <anna@addaleax.net>
Reviewed-By: Jon Moss <me@jonathanmoss.me>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Timothy Gu <timothygu99@gmail.com>
This commit is contained in:
Cameron Moorehead 2017-11-27 18:01:56 -08:00 committed by Anatoli Papirovski
parent df79b7d821
commit 1449c18bd8
No known key found for this signature in database
GPG Key ID: 614E2E1ABEB4B2C0

View File

@ -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`: