Skip to content

Instantly share code, notes, and snippets.

@psynewave
Created July 9, 2020 22:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save psynewave/449b0f1c10ef49587708f0420bccee0b to your computer and use it in GitHub Desktop.
Save psynewave/449b0f1c10ef49587708f0420bccee0b to your computer and use it in GitHub Desktop.
One liner for merging arrays with an optional unique flag
const mergeTwoArrays = (a, b, unique = false) => unique != true ? a.concat(b) : [...new Set([...a, ...b])];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment