Skip to content

Commit 4dc4272

Browse files
committed
minor
1 parent 2035e46 commit 4dc4272

File tree

1 file changed

+4
-2
lines changed
  • 1-js/04-object-basics/06-constructor-new

1 file changed

+4
-2
lines changed

1-js/04-object-basics/06-constructor-new/article.md

+4-2
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ let user = new function() {
8383
The constructor can't be called again, because it is not saved anywhere, just created and called. So this trick aims to encapsulate the code that constructs the single object, without future reuse.
8484
````
8585

86-
## Dual-syntax constructors: new.target
86+
## Constructor mode test: new.target
8787

8888
```smart header="Advanced stuff"
8989
The syntax from this section is rarely used, skip it unless you want to know everything.
@@ -109,7 +109,9 @@ new User(); // function User { ... }
109109
*/!*
110110
```
111111

112-
That can be used to allow both `new` and regular calls to work the same. That is, create the same object:
112+
That can be used inside the function to know whether it was called with `new`, "in constructor mode", or without it, "in regular mode".
113+
114+
We can also make both `new` and regular calls to do the same, like this:
113115

114116
```js run
115117
function User(name) {

0 commit comments

Comments
 (0)