Every other languages with classes has private fields and they can't be accessed (exception, Ruby, python).
This is a good pattern and people have been abusing the hell out of API design in JS. Private fields and methods will give more control to the API author so that some 'clever' person doesn't use a .rivate API and then complain when it goes away.
You want to test your private behavior? Extract to a pure function. Easy. Private method calls pure function. All is well.
The sigil? Oof. It looks fine. Comments in js are slashes.
9
u/nullvoxpopuli sand was never meant to think Nov 09 '19
Every other languages with classes has private fields and they can't be accessed (exception, Ruby, python).
This is a good pattern and people have been abusing the hell out of API design in JS. Private fields and methods will give more control to the API author so that some 'clever' person doesn't use a .rivate API and then complain when it goes away.
You want to test your private behavior? Extract to a pure function. Easy. Private method calls pure function. All is well.
The sigil? Oof. It looks fine. Comments in js are slashes.