Underscore prefixes for "private" properties
See original GitHub issueFrom the main section:
Use a leading underscore
_
when naming private properties.
From the React section:
Do not use underscore prefix for internal methods of a React component.
These two seem a bit inconsistent.
Issue Analytics
- State:
- Created 8 years ago
- Reactions:11
- Comments:36 (10 by maintainers)
Top Results From Across the Web
Is the underscore prefix for property and method names ...
_ prefixed variable names are considered private by convention but are still public. This syntax tries to be both terse and intuitive, although...
Read more >Configure Visual Studio to Name Private Fields with Underscore
Configure Visual Studio to Name Private Fields with Underscore · Click on Tools in the menu. · Click on Options. · Click on...
Read more >use of "_" prefix to designate "private"/"library" scope...
defines not only underscore as private, but and 'm' prefix as library ... and it isn't as easy to tell which properties are...
Read more >Using underscore to prefix private member fields
I personally prefer to use the underscore prefix on private member fields and mainly so they would be easily identifiable from local ...
Read more >Underscore prefix for private method names : r/PHP - Reddit
Underscore prefixes on function/method names is an old PHP 4 convention to indicate private. It's used in a number of languages that have...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
Top Related Hashnode Post
No results found
Top GitHub Comments
@taion if your goal is helpful suggestions, then name it
this.private_address_do_not_use
, orSECRET_DOM_DO_NOT_USE_OR_YOU_WILL_BE_FIRED
. Naming it_address
is just obscure.In principle, yes, but underscores are a widely understood indicator that a variable is “private”. You don’t walk through a door with a sock on the handle, even if it’s unlocked.
Since there are no private properties in ES6 classes, how can I indicate “private” methods and properties? This is especially problematic with getters/setters in ES6, since it needs to be stored in a separate variable.