Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Array.prototype.union = function(other) {
return [...new 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);
printOrders(allOrders);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.