Skip to content

Commit 387c088

Browse files
author
jessicarush
committed
Docs: update note
1 parent a16dcf0 commit 387c088

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

classes.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,18 +93,18 @@ console.log(user._name);
9393
// Scott
9494
```
9595

96-
However, ES2020 introduced...
96+
Note: ES2020 introduces real private variables and methods...
9797

9898

99-
## Private variables
99+
## Private variables and methods
100100

101101
ES2020 introduces [private class fields](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes/Private_class_fields).
102102

103103
Here's the example from above:
104104

105105
```javascript
106106
class Contact {
107-
// pivate fields must be declared first:
107+
// private fields must be declared first:
108108
#name;
109109
#email;
110110

@@ -135,6 +135,8 @@ console.log(user.#name);
135135
// SyntaxError
136136
```
137137

138+
The `#` can be applied to methods as well to make them private.
139+
138140

139141
## Inheritance
140142

0 commit comments

Comments
 (0)