title: How to customize object equality for JavaScript Set
body: <p>New ES 6 (Harmony) introduces new <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set" rel="noreferrer">Set</a> object. Identity algorithm used by Set is similar to <code>===</code> operator and so not much suitable for comparing objects:</p>
  
  <pre class="lang-js prettyprint-override"><code>var set = new Set();
  set.add({a:1});
  set.add({a:1});
  console.log([...set.values()]); // Array [ Object, Object ]
  </code></pre>
  
  <p>How to customize equality for Set objects in order to do deep object comparison? Is there anything like Java <code>equals(Object)</code>?</p>