Why does Javascript Set not do unique objects?
<p>Sets are supposed to contain unique objects, but it doesn't work for objects in javascript.</p>

<pre><code>var set = new Set()
&lt;- undefined
set.add({name:'a', value: 'b'})
&lt;- Set {Object {name: "a", value: "b"}}
set.add({name:'a', value: 'b'})
&lt;- Set {Object {name: "a", value: "b"}, Object {name: "a", value: "b"}}
</code></pre>

<p>It works for primitives</p>

<pre><code>var b = new Set()
&lt;- undefined
b.add(1)
&lt;- Set {1}
b.add(2)
&lt;- Set {1, 2}
b.add(1)
&lt;- Set {1, 2}
</code></pre>

<p>So how do I get it to work with objects?  I get the fact that they are different objects with the same values, but I'm looking for like a deep unique set.</p>

<p>EDIT:</p>

<p>Here's what I'm actually doing</p>

<pre><code>    var m = await(M.find({c: cID}).populate('p')) //database call
    var p = new Set();
    m.forEach(function(sm){
        p.add(sm.p)
    })
</code></pre>

<p>This is to get a unique list of sm.p</p>