Linux unitednationsplay.com 3.10.0-1160.45.1.el7.x86_64 #1 SMP Wed Oct 13 17:20:51 UTC 2021 x86_64
nginx/1.20.1
Server IP : 188.130.139.92 & Your IP : 18.191.120.131
Domains :
Cant Read [ /etc/named.conf ]
User : web
Terminal
Auto Root
Create File
Create Folder
Localroot Suggester
Backdoor Destroyer
Readme
/
usr /
share /
doc /
nodejs-docs-14.18.3 /
html /
guides /
Delete
Unzip
Name
Size
Permission
Date
Action
contributing
[ DIR ]
drwxr-xr-x
2022-01-26 16:43
doc_img
[ DIR ]
drwxr-xr-x
2022-01-26 16:43
adding-new-napi-api.md
2.55
KB
-rw-r--r--
2022-01-10 13:06
backporting-to-release-lines.md
4.38
KB
-rw-r--r--
2022-01-10 13:06
building-node-with-ninja.md
1.42
KB
-rw-r--r--
2022-01-10 13:06
collaborator-guide.md
40.27
KB
-rw-r--r--
2022-01-10 13:06
commit-queue.md
5.4
KB
-rw-r--r--
2022-01-10 13:06
cpp-style-guide.md
12.79
KB
-rw-r--r--
2022-01-10 13:06
diagnostic-tooling-support-tiers.md
8.66
KB
-rw-r--r--
2022-01-10 13:06
doc-style-guide.md
5.72
KB
-rw-r--r--
2022-01-10 13:06
internal-api.md
539
B
-rw-r--r--
2022-01-10 13:06
investigating_native_memory_leak.md
26.95
KB
-rw-r--r--
2022-01-10 13:06
maintaining-V8.md
17.66
KB
-rw-r--r--
2022-01-10 13:06
maintaining-c-ares.md
1.63
KB
-rw-r--r--
2022-01-10 13:06
maintaining-icu.md
8.27
KB
-rw-r--r--
2022-01-10 13:06
maintaining-npm.md
1.2
KB
-rw-r--r--
2022-01-10 13:06
maintaining-openssl.md
3.82
KB
-rw-r--r--
2022-01-10 13:06
maintaining-root-certs.md
3.57
KB
-rw-r--r--
2022-01-10 13:06
maintaining-the-build-files.md
2.39
KB
-rw-r--r--
2022-01-10 13:06
maintaining-zlib.md
892
B
-rw-r--r--
2022-01-10 13:06
node-postmortem-support.md
2.53
KB
-rw-r--r--
2022-01-10 13:06
offboarding.md
727
B
-rw-r--r--
2022-01-10 13:06
releases.md
34.1
KB
-rw-r--r--
2022-01-10 13:06
security-release-process.md
5.99
KB
-rw-r--r--
2022-01-10 13:06
strategic-initiatives.md
2.93
KB
-rw-r--r--
2022-01-10 13:06
technical-values.md
2.77
KB
-rw-r--r--
2022-01-10 13:06
using-internal-errors.md
4.9
KB
-rw-r--r--
2022-01-10 13:06
using-symbols.md
2.31
KB
-rw-r--r--
2022-01-10 13:06
writing-and-running-benchmarks.md
22.76
KB
-rw-r--r--
2022-01-10 13:06
writing-tests.md
15.83
KB
-rw-r--r--
2022-01-10 13:06
Save
Rename
# Using global symbols ES6 introduced a new type: `Symbol`. This new type is _immutable_, and it is often used for metaprogramming purposes, as it can be used as property keys like string. There are two types of symbols, local and global. Symbol-keyed properties of an object are not included in the output of `JSON.stringify()`, but the `util.inspect()` function includes them by default. Learn more about symbols at <https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Symbol>. ## `Symbol(string)` Symbols created via `Symbol(string)` are local to the caller function. For this reason, we often use them to simulate private fields, like so: ```js const kField = Symbol('kField'); console.log(kField === Symbol('kField')); // false class MyObject { constructor() { this[kField] = 'something'; } } module.exports.MyObject = MyObject; ``` Symbols are not fully private, as the data could be accessed anyway: ```js for (const s of Object.getOwnPropertySymbols(obj)) { const desc = s.toString().replace(/Symbol\((.*)\)$/, '$1'); if (desc === 'kField') { console.log(obj[s]); // 'something' } } ``` Local symbols make it harder for developers to monkey patch/access private fields, as they require more work than a property prefixed with an `_`. Monkey patching private API that were not designed to be monkey-patchable make maintaining and evolving Node.js harder, as private properties are not documented and can change within a patch release. Some extremely popular modules in the ecosystem monkey patch some internals, making it impossible for us to update and improve those areas without causing issues for a significant amount of users. ## `Symbol.for` Symbols created with `Symbol.for(string)` are global and unique to the same V8 Isolate. On the first call to `Symbol.for(string)` a symbol is stored in a global registry and easily retrieved for every call of `Symbol.for(string)`. However, this might cause problems when two module authors use the same symbol for different reasons. ```js const s = Symbol.for('hello'); console.log(s === Symbol.for('hello')); ``` In the Node.js runtime we prefix all our global symbols with `nodejs.`, e.g. `Symbol.for('nodejs.hello')`. Global symbols should be preferred when a developer-facing interface is needed to allow behavior customization, i.e., metaprogramming.