title: How to detect when object value change?
body: <p>I'm trying to listen when a object value changes using a Javascript <code>proxy object</code> in a easy and readable way. I followed <a href="https://stackoverflow.com/questions/1759987/listening-for-variable-changes-in-javascript">this</a> Stack Overflow question and Mozilla <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Proxy" rel="nofollow noreferrer">docs</a>. But I cannot understand how to do it to achieve my goal.</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>var values ={Value1: 0, Value2:0};
  var checkObjectChange = new Proxy(values, {});
  
  console.log("The object values are: "+JSON.stringify(values))
  
  $("#btn1").on("click", function() {
      values.Value1 = 1;
      console.log("Now the object values are: "+JSON.stringify(values));
  });
  
  $("#btn2").on("click", function() {
      values.Value2 = 1;
      console.log("Now the object values are: "+JSON.stringify(values));
  });
  
  //Im expecting to call a function when a object value changes
  function whenChange() {
    console.log("The value of the object has changed!");
  }</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"&gt;&lt;/script&gt;
  
  &lt;button id="btn1"&gt;Change value 1&lt;/button&gt;
  &lt;button id="btn2"&gt;Change value 2&lt;/button&gt;</code></pre>
  </div>
  </div>
  </p>