Friday, July 13, 2018

How to merge two arrays in JavaScript and de-duplicate items

I have two JavaScript arrays:



var array1 = ["Vijendra","Singh"];

var array2 = ["Singh", "Shakya"];


I want the output to be:



var array3 = ["Vijendra","Singh","Shakya"];


The output array should have repeated words removed.




How do I merge two arrays in JavaScript so that I get only the unique items from each array in the same order they were inserted into the original arrays?

No comments:

Post a Comment

plot explanation - Why did Peaches' mom hang on the tree? - Movies & TV

In the middle of the movie Ice Age: Continental Drift Peaches' mom asked Peaches to go to sleep. Then, she hung on the tree. This parti...