Use case suggestion: Get unique values from object array property
See original GitHub issueconst objects = [
{ id: 1 , category: "Cars", brand: "Subaru" },
{ id: 2 , category: "Cars", brand: "Ford" },
{ id: 3 , category: "Smatphones", brand: "Apple" },
{ id: 4 , category: "Cars", brand: "Citroen" },
];
categories = [...new Set(objects.map(object => object.category))];
console.log(categories);
//=> [ "Cars", "Smartphones" ]
Issue Analytics
- State:
- Created 6 years ago
- Reactions:2
- Comments:5 (5 by maintainers)
Top Results From Across the Web
Create array of unique objects by property - javascript
Below is a general function to obtain a unique array of objects based on a specific property ( prop ) from an array...
Read more >How to Find Unique Values by Property in an Array of Objects ...
Let's find the distinct values for a given property among all of the JavaScript objects in an array in this short tutorial.
Read more >How to Get Distinct Values From an Array of Objects in ...
One way to get distinct values from an array of JavaScript objects is to use the array's map method to get an array...
Read more >How to Find Unique Values of a Specific Key in an Array of ...
In this article we'll cover two separate algorithms to accomplish this and wrap up the guide with a recommendation for generalizing the strategy ......
Read more >Compare two array's by object and compose unique r...
I have two arrays of objects that I'm trying to compare. I only want to keep the records that are unique and write...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
🎬, more info on #97
Now I see that could be maybe just remove duplicates in array.