What makes array to merge in JavaScript?
Actually there aren’t so many array functions in JavaScript. As you know you can join, sort, etc. which methods are pretty basic. What I’d like to do is something similar to PHPs’ array_merge and than array_unique.
With JavaScript that seems pretty impossible. You can merge them with the .concat function as in the example bellow:
var a = [1,2]; var b = [3,4]; a.concat(b);
this gives you array with four elements. But when it comes to trim all the duplicates as it’s array_unique in PHP, well that’s really impossible. You’ve to do it by yourself, and I don’t thing this is the best technique. That slows down the code and you should avoid it!
Related posts:










var a = [1,2];
var b = [3,4];
var c=(a+’,'+b).split(‘,’);
c equal to a.concat(b)