doc: remove "note that" from using-symbols.md
Refs: https://github.com/nodejs/remark-preset-lint-node/pull/16 PR-URL: https://github.com/nodejs/node/pull/28329 Reviewed-By: Gus Caplan <me@gus.host> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com> Reviewed-By: Tobias Nießen <tniessen@tnie.de> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
This commit is contained in:
parent
68cfa56d0c
commit
ebf5822f12
@ -14,7 +14,6 @@ https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Symbo
|
|||||||
## `Symbol(string)`
|
## `Symbol(string)`
|
||||||
|
|
||||||
Symbols created via `Symbol(string)` are local to the caller function.
|
Symbols created via `Symbol(string)` are local to the caller function.
|
||||||
Note that `Symbol('hello') !== Symbol('hello')`.
|
|
||||||
For this reason, we often use them to simulate private fields, like so:
|
For this reason, we often use them to simulate private fields, like so:
|
||||||
|
|
||||||
```js
|
```js
|
||||||
@ -31,8 +30,7 @@ class MyObject {
|
|||||||
module.exports.MyObject = MyObject;
|
module.exports.MyObject = MyObject;
|
||||||
```
|
```
|
||||||
|
|
||||||
Note that Symbols are not _fully private_, as the data could be accessed
|
Symbols are not fully private, as the data could be accessed anyway:
|
||||||
anyway:
|
|
||||||
|
|
||||||
```js
|
```js
|
||||||
for (const s of Object.getOwnPropertySymbols(obj)) {
|
for (const s of Object.getOwnPropertySymbols(obj)) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user