Update JS style guide with rule for prefixing private class methods with an underscore. (#20851) (#20891)

This commit is contained in:
CJ Cenizal 2018-07-17 10:00:32 -07:00 committed by GitHub
parent 7a09570e2f
commit cb774024d1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -215,6 +215,20 @@ class bank_account {}
class bankAccount {}
```
## Prefix private class methods with an underscore
Identifying private class methods makes it easier to differentiate a class's public and internal
APIs, and makes private methods easier to mark as `private` when the code is migrated to TypeScript.
```js
// good
class BankAccount {
addFunds() {}
_calculateInterest() {}
}
```
## Magic numbers/strings
These are numbers (or other values) simply used in line in your code. *Do not