title: How to remove duplicate object property in Javascript array
body: <p>I have an array of messages between me and different other users, I am trying to filter this array to only contain a single occurrence of a user (e.g In this array there are 10 messages between me and John, where I've been either a sender or a receiver), I'm trying to get a new array containing only a single occurrence of John, the latest message (be it john as a sender or receiver). I also have two messages between me and Jane, (in one I was the sender, the other message I was the receiver), I would like to also have only a single occurrence of messages between me and Jane.</p>
  <p>So at the end I'm trying to have an array containing three messages,</p>
  <p>-one with Thomas</p>
  <p>-one with Jane</p>
  <p>-one with John</p>
  <p>If anyone has a solution pls share</p>
  <pre><code>[
  {
      &quot;_id&quot;: &quot;5f58b7a4075626065aaa752a&quot;,
      &quot;message&quot;: &quot;Hi&quot;,
      &quot;receiver&quot;: &quot;5f004feae528a90017327f3b&quot;,
      &quot;sender&quot;: &quot;5f4ea9d045cc6b736870a076&quot;,
      &quot;senderInfo&quot;: {
          &quot;_id&quot;: &quot;5f58b7a4075626065aaa752b&quot;,
          &quot;name&quot;: &quot;Thomas&quot;,
      },
      &quot;receiverInfo&quot;: {
          &quot;_id&quot;: &quot;5f58b7a4075626065aaa752c&quot;,
          &quot;name&quot;: &quot;ME&quot;,
      }
  },
  {
      &quot;_id&quot;: &quot;5f57f190075626065aaa600d&quot;,
      &quot;message&quot;: &quot;When I click on \&quot;go to session\&quot;, I just see myself. I doubt the connection was established&quot;,
      &quot;receiver&quot;: &quot;5f4e646822ab43702ee29ebb&quot;,
      &quot;sender&quot;: &quot;5f004feae528a90017327f3b&quot;,
      &quot;senderInfo&quot;: {
          &quot;_id&quot;: &quot;5f57f190075626065aaa600e&quot;,
          &quot;name&quot;: &quot;Me&quot;,
      },
      &quot;receiverInfo&quot;: {
          &quot;_id&quot;: &quot;5f57f190075626065aaa600f&quot;,
          &quot;name&quot;: &quot;John&quot;,
      }
  },
  {
      &quot;_id&quot;: &quot;5f57f08d075626065aaa5eed&quot;,
      &quot;message&quot;: &quot;I think I lost all the calls. The session takes a while to load&quot;,
      &quot;receiver&quot;: &quot;5f4e646822ab43702ee29ebb&quot;,
      &quot;sender&quot;: &quot;5f004feae528a90017327f3b&quot;,
      &quot;senderInfo&quot;: {
          &quot;_id&quot;: &quot;5f57f08d075626065aaa5eee&quot;,
          &quot;name&quot;: &quot;Me &quot;,
      },
      &quot;receiverInfo&quot;: {
          &quot;_id&quot;: &quot;5f57f08d075626065aaa5eef&quot;,
          &quot;name&quot;: &quot;John&quot;,
  
      }
  },
  {
      &quot;_id&quot;: &quot;5f57f068075626065aaa5eae&quot;,
      &quot;message&quot;: &quot;Kk&quot;,
      &quot;receiver&quot;: &quot;5f004feae528a90017327f3b&quot;,
      &quot;sender&quot;: &quot;5f4e646822ab43702ee29ebb&quot;,
      &quot;senderInfo&quot;: {
          &quot;_id&quot;: &quot;5f57f068075626065aaa5eaf&quot;,
          &quot;name&quot;: &quot;John&quot;,
      },
      &quot;receiverInfo&quot;: {
          &quot;_id&quot;: &quot;5f57f068075626065aaa5eb0&quot;,
          &quot;name&quot;: &quot;Me&quot;,
      },
  },
  {
      &quot;_id&quot;: &quot;5f57efd3075626065aaa5e2d&quot;,
      &quot;message&quot;: &quot;I'm available now&quot;,
      &quot;receiver&quot;: &quot;5f4e646822ab43702ee29ebb&quot;,
      &quot;sender&quot;: &quot;5f004feae528a90017327f3b&quot;,
      &quot;senderInfo&quot;: {
          &quot;_id&quot;: &quot;5f57efd3075626065aaa5e2e&quot;,
          &quot;name&quot;: &quot;Me&quot;
      },
      &quot;receiverInfo&quot;: {
          &quot;_id&quot;: &quot;5f57efd3075626065aaa5e2f&quot;,
          &quot;name&quot;: &quot;John&quot;,
      }
  },
  {
      &quot;_id&quot;: &quot;5f57ee75075626065aaa5dcb&quot;,
      &quot;message&quot;: &quot;Ok&quot;,
      &quot;receiver&quot;: &quot;5f4e646822ab43702ee29ebb&quot;,
      &quot;sender&quot;: &quot;5f004feae528a90017327f3b&quot;,
      &quot;senderInfo&quot;: {
          &quot;_id&quot;: &quot;5f57ee75075626065aaa5dcc&quot;,
          &quot;name&quot;: &quot;Me&quot;,
      },
      &quot;receiverInfo&quot;: {
          &quot;_id&quot;: &quot;5f57ee75075626065aaa5dcd&quot;,
          &quot;name&quot;: &quot;John&quot;,
      }
  },
  {
      &quot;_id&quot;: &quot;5f57ee5f075626065aaa5d99&quot;,
      &quot;message&quot;: &quot;Mark available let me try &quot;,
      &quot;receiver&quot;: &quot;5f004feae528a90017327f3b&quot;,
      &quot;sender&quot;: &quot;5f4e646822ab43702ee29ebb&quot;,
      &quot;attachment&quot;: null,
      &quot;type&quot;: 1,
      &quot;senderInfo&quot;: {
          &quot;_id&quot;: &quot;5f57ee5f075626065aaa5d9a&quot;,
          &quot;name&quot;: &quot;John&quot;
      },
      &quot;receiverInfo&quot;: {
          &quot;_id&quot;: &quot;5f57ee5f075626065aaa5d9b&quot;,
          &quot;name&quot;: &quot;Me&quot;
      }
  },
  {
      &quot;_id&quot;: &quot;5f57ee23075626065aaa5d6d&quot;,
      &quot;message&quot;: &quot;I got the notification but it just didn't connect&quot;,
      &quot;receiver&quot;: &quot;5f4e646822ab43702ee29ebb&quot;,
      &quot;sender&quot;: &quot;5f004feae528a90017327f3b&quot;,
      &quot;senderInfo&quot;: {
          &quot;_id&quot;: &quot;5f57ee23075626065aaa5d6e&quot;,
          &quot;name&quot;: &quot;Me&quot;
      },
      &quot;receiverInfo&quot;: {
          &quot;_id&quot;: &quot;5f57ee23075626065aaa5d6f&quot;,
          &quot;name&quot;: &quot;John&quot;,
      }
  },
  {
      &quot;_id&quot;: &quot;5f57ede3075626065aaa5d46&quot;,
      &quot;message&quot;: &quot;Didn't go&quot;,
      &quot;receiver&quot;: &quot;5f004feae528a90017327f3b&quot;,
      &quot;sender&quot;: &quot;5f4e646822ab43702ee29ebb&quot;,
      &quot;senderInfo&quot;: {
          &quot;_id&quot;: &quot;5f57ede3075626065aaa5d47&quot;,
          &quot;name&quot;: &quot;John&quot;,
      },
      &quot;receiverInfo&quot;: {
          &quot;_id&quot;: &quot;5f57ede3075626065aaa5d48&quot;,
          &quot;name&quot;: &quot;Me&quot;,
      }
  },
  {
      &quot;_id&quot;: &quot;5f57edd9075626065aaa5d38&quot;,
      &quot;message&quot;: &quot;I tried to call&quot;,
      &quot;receiver&quot;: &quot;5f004feae528a90017327f3b&quot;,
      &quot;sender&quot;: &quot;5f4e646822ab43702ee29ebb&quot;,
      &quot;senderInfo&quot;: {
          &quot;_id&quot;: &quot;5f57edd9075626065aaa5d39&quot;,
          &quot;name&quot;: &quot;John&quot;,
      },
      &quot;receiverInfo&quot;: {
          &quot;_id&quot;: &quot;5f57edd9075626065aaa5d3a&quot;,
          &quot;name&quot;: &quot;Me&quot;,
      }
  },
  {
      &quot;_id&quot;: &quot;5f57ed8a075626065aaa5d19&quot;,
      &quot;message&quot;: &quot;Hi&quot;,
      &quot;receiver&quot;: &quot;5f4e646822ab43702ee29ebb&quot;,
      &quot;sender&quot;: &quot;5f004feae528a90017327f3b&quot;,
      &quot;senderInfo&quot;: {
          &quot;_id&quot;: &quot;5f57ed8a075626065aaa5d1a&quot;,
          &quot;name&quot;: &quot;Me&quot;,
      },
      &quot;receiverInfo&quot;: {
          &quot;_id&quot;: &quot;5f57ed8a075626065aaa5d1b&quot;,
          &quot;name&quot;: &quot;John&quot;,
      },
  },
  
  {
      &quot;_id&quot;: &quot;5f58b7a4075626065aaa752a&quot;,
      &quot;message&quot;: &quot;Hi&quot;,
      &quot;receiver&quot;: &quot;5f004feae528a90017327f3b&quot;,
      &quot;sender&quot;: &quot;5f4ea9d045cc6b736870a076&quot;,
      &quot;senderInfo&quot;: {
          &quot;_id&quot;: &quot;5f58b7a4075626065aaa752b&quot;,
          &quot;name&quot;: &quot;Jane&quot;,
      },
      &quot;receiverInfo&quot;: {
          &quot;_id&quot;: &quot;5f58b7a4075626065aaa752c&quot;,
          &quot;name&quot;: &quot;ME&quot;,
      }
  },
  
  {
      &quot;_id&quot;: &quot;5f58b7a4075626065aaa752a&quot;,
      &quot;message&quot;: &quot;Hi&quot;,
      &quot;receiver&quot;: &quot;5f004feae528a90017327f3b&quot;,
      &quot;sender&quot;: &quot;5f4ea9d045cc6b736870a076&quot;,
      &quot;receiverInfo&quot;: {
          &quot;_id&quot;: &quot;5f58b7a4075626065aaa752b&quot;,
          &quot;name&quot;: &quot;Jane&quot;,
      },
      &quot;senderInfo&quot;: {
          &quot;_id&quot;: &quot;5f58b7a4075626065aaa752c&quot;,
          &quot;name&quot;: &quot;ME&quot;,
      }
  },
  
  ]
  </code></pre>