Linux localhost 5.4.0-198-generic #218-Ubuntu SMP Fri Sep 27 20:18:53 UTC 2024 x86_64
Apache/2.4.41 (Ubuntu)
: 23.92.16.63 | : 104.23.253.119
Cant Read [ /etc/named.conf ]
8.1.5
www-data
www.github.com/MadExploits
Terminal
AUTO ROOT
Adminer
Backdoor Destroyer
Linux Exploit
Lock Shell
Lock File
Create User
CREATE RDP
PHP Mailer
BACKCONNECT
UNLOCK SHELL
HASH IDENTIFIER
CPANEL RESET
CREATE WP USER
README
+ Create Folder
+ Create File
/
usr /
share /
doc /
nodejs /
contributing /
[ HOME SHELL ]
Name
Size
Permission
Action
doc_img
[ DIR ]
drwxr-xr-x
maintaining
[ DIR ]
drwxr-xr-x
adding-new-napi-api.md
2.55
KB
-rw-r--r--
adding-v8-fast-api.md
5.06
KB
-rw-r--r--
api-documentation.md
15.36
KB
-rw-r--r--
backporting-to-release-lines.m...
5.72
KB
-rw-r--r--
building-node-with-ninja.md
1.72
KB
-rw-r--r--
code-of-conduct.md
2.12
KB
-rw-r--r--
collaborator-guide.md
43.49
KB
-rw-r--r--
commit-queue.md
5.76
KB
-rw-r--r--
components-in-core.md
2.51
KB
-rw-r--r--
cpp-style-guide.md
12.81
KB
-rw-r--r--
diagnostic-tooling-support-tie...
8
KB
-rw-r--r--
feature-request-management.md
3.41
KB
-rw-r--r--
internal-api.md
539
B
-rw-r--r--
investigating-native-memory-le...
30.58
KB
-rw-r--r--
issues.md
3.31
KB
-rw-r--r--
node-postmortem-support.md
2.53
KB
-rw-r--r--
offboarding.md
1.13
KB
-rw-r--r--
primordials.md
21.85
KB
-rw-r--r--
pull-requests.md
24.74
KB
-rw-r--r--
releases-node-api.md
6.63
KB
-rw-r--r--
releases.md
45.29
KB
-rw-r--r--
security-model-strategy.md
2.81
KB
-rw-r--r--
security-release-process.md
10.06
KB
-rw-r--r--
security-steward-on-off-boardi...
1.02
KB
-rw-r--r--
sharing-project-news.md
1.45
KB
-rw-r--r--
static-analysis.md
798
B
-rw-r--r--
strategic-initiatives.md
3.26
KB
-rw-r--r--
streaming-to-youtube.md
4.51
KB
-rw-r--r--
suggesting-social-media-posts....
257
B
-rw-r--r--
technical-priorities.md
6.02
KB
-rw-r--r--
technical-values.md
2.79
KB
-rw-r--r--
using-internal-errors.md
5.05
KB
-rw-r--r--
using-symbols.md
2.33
KB
-rw-r--r--
writing-and-running-benchmarks...
23.5
KB
-rw-r--r--
writing-tests.md
16.05
KB
-rw-r--r--
Delete
Unzip
Zip
${this.title}
Close
Code Editor : using-symbols.md
# 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(string)` 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')); // true ``` 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.
Close