Skip to content

Instantly share code, notes, and snippets.

@nhuxhr
Created July 21, 2021 22:47
Show Gist options
  • Save nhuxhr/2eb929cb36b1001c99a4ac1ab7b5f7ce to your computer and use it in GitHub Desktop.
Save nhuxhr/2eb929cb36b1001c99a4ac1ab7b5f7ce to your computer and use it in GitHub Desktop.
Remove duplicates from an Array in JavaScript
/**
* Remove duplicates from an Array in JavaScript
* @author JSX Clan <jsxclan.dev@gmail.com>
*/
const array = [0, 1, 0, 'foo', 'bar', 'bar', true, true, false];
const filteredArray = [...new Set(array)];
console.log(filteredArray);
// Output: [0, 1, "foo", "bar", true, false]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment