Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Array.prototype.union = function(other) {
return [ Set([...this, ...other])];
// SQL has "UNION ALL" that combines two sets without dropping duplicates.
// Array.prototype.unionAll = function(other) {
// return [...this, ...other];
// };
function unionDemo(domesticOrders, internationalOrders) {
const allOrders = domesticOrders.union(internationalOrders);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment