I have the following JS array:
var myArray = [{name:"Bob",b:"text2",c:true},
{name:"Tom",b:"text2",c:true},
{name:"Adam",b:"text2",c:true},
{name:"Tom",b:"text2",c:true},
{name:"Bob",b:"text2",c:true}
];
I want to exclude indexes with duplicate names and recreate a new array with different names, for example:
var mySubArray = [{name:"Bob",b:"text2",c:true},
{name:"Tom",b:"text2",c:true},
{name:"Adam",b:"text2",c:true},
];
As you can see, I deleted “Bob” and “Tom”, leaving only 3 different names. Is this possible with Underscore? How?
user1094081
source
share