Merge two arrays : merge « jQuery « JavaScript Tutorial






<html>
  <head>
    <script type='text/javascript' src='js/jquery-1.3.2.js'></script>
    <script type='text/javascript'>
$(document).ready(
  function() {
    var $vegetables = [
      'C',
      'T',
      'L'
    ];
    var $fruits = [
      'C',
      'A',
      'C'                   
    ];
    
    $merged = $.merge($vegetables, $fruits);
    var $string = '';
    $($merged).each(
      function() {
         $string += this + "\n";   
      }
    );
    
    alert($string);
  }
);
    </script>
  </head>
  <body>
  </body>
</html>








30.67.merge
30.67.1.Merge array
30.67.2.Merge two arrays
30.67.3.Merge array and get the unique