title: Javascript Syntax Ask
body: <p>I am studying the core javascript, and met the following code (<a href="https://javascript.info/private-protected-properties-methods#protecting-wateramount" rel="nofollow noreferrer">https://javascript.info/private-protected-properties-methods#protecting-wateramount</a>)</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>class CoffeeMachine {
    waterAmount = 0; // the amount of water inside
  
    constructor(power) {
      this.power = power;
      alert(`Created a coffee-machine, power: ${power}`);
    }
  
  }
  
  // create the coffee machine
  let coffeeMachine = new CoffeeMachine(100);
  
  // add water
  coffeeMachine.waterAmount = 200;</code></pre>
  </div>
  </div>
  </p>
  
  <p>Line 2, <code>waterAmount = 0</code> run in browser environment, but not in node environment, saying</p>
  
  <pre><code>  waterAmount = 0;
                ^
  
  SyntaxError: Unexpected token =
      at new Script (vm.js:80:7)
      at createScript (vm.js:274:10)
  </code></pre>
  
  <p>How come? So line 2 is not a good practice, I assume?
  Thanks for shedding light.</p>