We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent a16dcf0 commit 387c088Copy full SHA for 387c088
classes.md
@@ -93,18 +93,18 @@ console.log(user._name);
93
// Scott
94
```
95
96
-However, ES2020 introduced...
+Note: ES2020 introduces real private variables and methods...
97
98
99
-## Private variables
+## Private variables and methods
100
101
ES2020 introduces [private class fields](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes/Private_class_fields).
102
103
Here's the example from above:
104
105
```javascript
106
class Contact {
107
- // pivate fields must be declared first:
+ // private fields must be declared first:
108
#name;
109
#email;
110
@@ -135,6 +135,8 @@ console.log(user.#name);
135
// SyntaxError
136
137
138
+The `#` can be applied to methods as well to make them private.
139
+
140
141
## Inheritance
142
0 commit comments