Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 1eff647

Browse filesBrowse 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 <anna@addaleax.net> Reviewed-By: Jon Moss <me@jonathanmoss.me> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Timothy Gu <timothygu99@gmail.com>
1 parent fb3ea4c commit 1eff647
Copy full SHA for 1eff647

File tree

Expand file treeCollapse file tree

1 file changed

+3
-3
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

1 file changed

+3
-3
lines changed
Open diff view settings
Collapse file

‎doc/api/modules.md‎

Copy file name to clipboardExpand all lines: doc/api/modules.md
+3-3Lines changed: 3 additions & 3 deletions
  • Display the source diff
  • Display the rich diff
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 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.