1. Native JavaScript implementation
var array1 = ["a", "b"]; var array2 = ["c", "d"];
I want to merge it into something like this:
<span class="keyword" style="font-weight:bold">var</span> <span class="keyword" style="font-weight:bold">array</span>= [<span class="string" style="color:rgb(221,17,68)">"a"</span>, <span class="string" style="color:rgb(221,17,68)">"b"</span>, <span class="string" style="color:rgb(221,17,68)">"c"</span>, <span class="string" style="color:rgb(221,17,68)">"d"</span>];
Can be used
arr1.concat(arr2);
2. Jquery implementation
$.merge(array1,array2); console.log($.unique(array1));