Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save vinicioslc/ecafcfb5b18050118c4aeeba81912c1a to your computer and use it in GitHub Desktop.
Save vinicioslc/ecafcfb5b18050118c4aeeba81912c1a to your computer and use it in GitHub Desktop.
A good remove duplicates function in nodejs that uses good readability principles and performance concepts like hashmaps
const removeDuplicateStrings = (array) => {
const uniqueValues = [];
const seenMap = {};
for (const item of array) {
if (seenMap[item]) continue;
seenMap[item] = true;
uniqueValues.push(item);
}
return uniqueValues;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment