首页 > 代码库 > Sorted Union

Sorted Union

function unite(arr1, arr2, arr3) {
  //return arr1;
  var args = Array.from(arguments);
  var arr = args.reduce(function(pre,cur,index,array){
    return pre.concat(cur);
  });
  return arr.filter(function(item,index,array){
    return arr.indexOf(item) === index;
  });
}

unite([1, 3, 2], [5, 2, 1, 4], [2, 1]);

  

Sorted Union