Ranter
Join devRant
Do all the things like
++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
Learn More
Comments
-
dexie15388yWell, naming privates with underscore in front is common practice. Can't see why you are mad
-
crisz81918yBecause you have visibility keywords for it. What's the purpose to type "private" if then you have to put an underscore?
-
dexie15388y@crisz because I might want to create public attribute with the same name, but it is already taken by private attribute. Imagine you have car object and it has private _speed stored. Then, you want to make read-only public field speed, with only getter. You may use GetSpeed() instead, but that's much, much worse.
-
Root797348yThe leading underscore makes it extremely obvious at-a-glance that the var is private. This improves code readability and is consistent with many other languages. It's expected and standard.
To hate this is like hating people who use coffee cups for coffee.
I hate people who put underscore at the beginning of private variables names in Typescript. And I don't care if they have their reasons, I just hate them.
undefined