I’m translating some Clojure code to Javascript for my job for transparency for the UI team and I realized why I prefer Clojure for Javascript. Here's the problem:

Select only unique objects from a list

Javascript:

const myDistinctArray = [
...new Set(myObjArray.map(JSON.stringify)),
].map(JSON.parse);

or

// This one presumes unique "id" === unique object 
let uniqueObjArray = […

--

--

Ovidiu Stoica

Ovidiu Stoica

Hi, I’m Ovi Stoica! I help people build quality software and I write about technology, startups and marketing for developers.