I have an array as follows:
const arr = [
{company: 'a', date: '1'},
{company: 'b', date: '1'},
{company: 'c', date: '1'},
{company: 'a', date: '2'},
{company: 'a', date: '1'},
{company: 'b', date: '2'},
]
I just want to know how to get the unique objects inside it. I tried using lodash with this command:
uniqBy(arr, 'date');
But it only returns:
[
{company: "a", date: "1"},
{company: "a", date: "2"}
]
I want something like this one:
[
{company: "a", date: "1"},
{company: "a", date: "2"},
{company: "b", date: "1"},
{company: "b", date: "2"},
{company: "c", date: "1"},
]
Is there a way in lodash or vanilla JS to have this done?