title: jquery/javascript merge array with same id
body: <p>I have these below array result:</p>
  <pre><code>[
  {&quot;timeNameID&quot;:&quot;2&quot;,&quot;alarmID&quot;:&quot;1&quot;},
  {&quot;timeNameID&quot;:&quot;3&quot;,&quot;alarmID&quot;:&quot;2&quot;},
  {&quot;timeNameID&quot;:&quot;4&quot;,&quot;alarmID&quot;:&quot;3&quot;},
  {&quot;timeNameID&quot;:&quot;5&quot;,&quot;alarmID&quot;:&quot;1&quot;},
  {&quot;timeNameID&quot;:&quot;6&quot;,&quot;alarmID&quot;:&quot;2&quot;},
  {&quot;timeNameID&quot;:&quot;7&quot;,&quot;alarmID&quot;:&quot;2&quot;},
  
  {&quot;timeNameID&quot;:&quot;2&quot;,&quot;alarmID&quot;:&quot;2&quot;},
  {&quot;timeNameID&quot;:&quot;4&quot;,&quot;alarmID&quot;:&quot;1&quot;},
  {&quot;timeNameID&quot;:&quot;5&quot;,&quot;alarmID&quot;:&quot;1&quot;},
  {&quot;timeNameID&quot;:&quot;6&quot;,&quot;alarmID&quot;:&quot;2&quot;},
  {&quot;timeNameID&quot;:&quot;7&quot;,&quot;alarmID&quot;:&quot;4&quot;}
  ]
  </code></pre>
  <p>from this JS script:</p>
  <pre><code>var post_str = []
  $('.alarm1, .alarm2').each(function ()
  {
      var timeNameID = $(this).attr('id'),
          alarmID = $(this).find(':selected').val()
                      
          post_str.push({
              'timeNameID': timeNameID,
              'alarmID': alarmID
          });
  });
                  
  alert(JSON.stringify(post_str));
  </code></pre>
  <p>Now I need to merge that array with same <code>timeNameID</code>, to be like this:</p>
  <pre><code>[
  {&quot;timeNameID&quot;:&quot;2&quot;,&quot;alarmID&quot;:&quot;1&quot;,&quot;alarmID2&quot;:&quot;2&quot;},
  {&quot;timeNameID&quot;:&quot;3&quot;,&quot;alarmID&quot;:&quot;2&quot;,&quot;alarmID2&quot;:&quot;&quot;}, //null/empty
  {&quot;timeNameID&quot;:&quot;4&quot;,&quot;alarmID&quot;:&quot;3&quot;,&quot;alarmID2&quot;:&quot;1&quot;},
  {&quot;timeNameID&quot;:&quot;5&quot;,&quot;alarmID&quot;:&quot;1&quot;,&quot;alarmID2&quot;:&quot;1&quot;},
  {&quot;timeNameID&quot;:&quot;6&quot;,&quot;alarmID&quot;:&quot;2&quot;,&quot;alarmID2&quot;:&quot;2&quot;},
  {&quot;timeNameID&quot;:&quot;7&quot;,&quot;alarmID&quot;:&quot;2&quot;,&quot;alarmID2&quot;:&quot;4&quot;}
  ]
  </code></pre>
  <p>Is it possible to do that array merge to be like my above expected?</p>