Created
May 15, 2019 06:31
-
-
Save kenpeter/d2ebd58ebc481e847e8356e030c78006 to your computer and use it in GitHub Desktop.
How to union two array in javascript
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// arr1 | |
var a = [34, 35, 45, 48, 49]; | |
// arr2 | |
var b = [48, 55]; | |
// spread a, spread b | |
// into Set obj (unique) | |
// sreapd again, inject to arr | |
var union = [...new Set([...a, ...b])]; | |
console.log(union); | |
From: | |
https://stackoverflow.com/questions/3629817/getting-a-union-of-two-arrays-in-javascript |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment