How to define private methods in a JS Class
问题 I'm trying to define a private method for a class to test that such a method can't be called from outside the class. However, I'm coming across an error even when I'm using the syntax as indicated in the Specification. I also checked MDN. Here's the code for my class: class CoffeeMachine { #waterLimit = 200; #checkWater(value) { if (value < 0) throw new Error("Negative water"); if (value > this.#waterLimit) throw new Error("Too much water"); } } Upon calling coffeeMachine.#checkWater(); , I'm