We will observe the following steps:
setout of the merged array, removing duplicates.
Let's take a look at an example.
// given first array const fruits1 = ["apples", "oranges"]; //given second array const fruits2 = ["oranges", "grapes", "guava"]; //display the merged array after removing duplicates console.log(Array.from(new Set(fruits1.concat(fruits2))));
In the above code snippet:
concat()method on the first array
fruits1and pass the second array
fruits2as a second parameter. This will return the merged array. Next, we will pass this merged array to a set, which removes duplicates from it. Now, we will pass this
setto array and display the returned array.
View all Courses