That is not enforced on the language level, but there’s a well-known convention between programmers that such properties and methods should not be accessed from the outside.
Now the access is under control, so setting the water amount below zero becomes impossible.
Read-only “power”
If we inherit class MegaMachine extends CoffeeMachine, then nothing prevents us from accessing this._waterAmount or this._power from the methods of the new class.
Privates should start with #. They are only accessible from inside the class.
Glasp is a social web highlighter that people can highlight and organize quotes and thoughts from the web, and access other like-minded people’s learning.