---
title: "Vipul Bhardwaj (@vipulbhj) | Hashnode"
description: "Learner. Read the latest articles by Vipul Bhardwaj on Hashnode."
url: "https://hashnode.com/@vipulbhj"
---

@vipulbhj

# Vipul Bhardwaj

@vipulbhj · Narnaul, India · Joined February 2021

Learner

## Comments

[@thebarefootdev Yes, but I wanted to keep it simple and that was the metic used in the benchmarks on the article. Also specs of my system won't matter since I am running both on the same machine. If you do a more comprehensive comparisons, do let me know. P.S: Please leave a like if you like the content :p](https://hashnode.com/posts/a-better-way-to-remove-duplicate-objects-from-array-in-javascript/60b8cfafe7631679eb8dd1bd/comment/60b91a1ee7631679eb8dd937#reply-60b92899d7e1e779f671c0b5)

Reply · Article · Jun 3, 2021 · [A better way to remove duplicate Objects from Array in Javascript](https://hashnode.com/posts/a-better-way-to-remove-duplicate-objects-from-array-in-javascript/60b8cfafe7631679eb8dd1bd)

[@thebarefootdev I have also made a video of the whole process, you can check it out here. https://www.dropbox.com/s/0z7m740wxii4p98/Comment%20Algorithm%20Experiment.mov?dl=0](https://hashnode.com/posts/a-better-way-to-remove-duplicate-objects-from-array-in-javascript/60b8cfafe7631679eb8dd1bd/comment/60b91a1ee7631679eb8dd937#reply-60b9271be7631679eb8dda79)

Reply · Article · Jun 3, 2021 · [A better way to remove duplicate Objects from Array in Javascript](https://hashnode.com/posts/a-better-way-to-remove-duplicate-objects-from-array-in-javascript/60b8cfafe7631679eb8dd1bd)

[@thebarefootdev const data = require('./generated.json'); // 7000 plus rows in the test data. function algorithmSuggestedInComments(arr) { return \[... new Set(arr.map(JSON.stringify))\].map(JSON.parse); } function removeDuplicates(arr) { const result = \[\]; const lookedAtNodes = new Set(); // prepass const modifiedArr = arr.map(JSON.stringify); modifiedArr.forEach((elem, idx) => { if(!lookedAtNodes.has(elem)) { result.push(arr\[idx\]); lookedAtNodes.add(elem); } }); return result; } console.time("Algorithm suggested in Comments"); algorithmSuggestedInComments(data); console.timeEnd("Algorithm suggested in Comments"); console.time("Algorithm mentioned in the article"); removeDuplicates(data); console.timeEnd("Algorithm mentioned in the article"); > node ./algo.js Algorithm suggested in Comments: 111.192ms Algorithm mentioned in the article: 54.276ms](https://hashnode.com/posts/a-better-way-to-remove-duplicate-objects-from-array-in-javascript/60b8cfafe7631679eb8dd1bd/comment/60b91a1ee7631679eb8dd937#reply-60b925e8d7e1e779f671c08c)

Reply · Article · Jun 3, 2021 · [A better way to remove duplicate Objects from Array in Javascript](https://hashnode.com/posts/a-better-way-to-remove-duplicate-objects-from-array-in-javascript/60b8cfafe7631679eb8dd1bd)

[Because doing JSON.parse will be expensive in comparison to the current implementation. Imagine very large JSON Objects, parse is far more expensive than a loop. I will try to run both the implementations on the big dataset and share the results here.](https://hashnode.com/posts/a-better-way-to-remove-duplicate-objects-from-array-in-javascript/60b8cfafe7631679eb8dd1bd/comment/60b91a1ee7631679eb8dd937#reply-60b91f71d7e1e779f671c041)

Reply · Article · Jun 3, 2021 · [A better way to remove duplicate Objects from Array in Javascript](https://hashnode.com/posts/a-better-way-to-remove-duplicate-objects-from-array-in-javascript/60b8cfafe7631679eb8dd1bd)
