The One Thing That Made Me Choose Clojure Over Javascript — How Simplicity Wins

Select only unique objects from a list


const myDistinctArray = [ Set(,
// This one presumes unique "id" === unique object 
let uniqueObjArray = [ Map( => [item["id"], item])


(distinct my-object-list) // that's it

Why does the Clojure one work?

Clojure promotes immutability by default, and this includes maps. So maps are compared directly by value and not by reference or identity.


The beautiful thing about Clojure is how expressive the language is and how much you can say with very few lines of code.



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
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.