title: Dynamically building array, appending values
body: <p>i have a bunch of <code>options</code> in this <code>select</code>, each with <code>value</code>s like:</p>
  
  <pre><code>context|cow
  context|test
  thing|1
  thing|5
  thing|27
  context|beans 
  </code></pre>
  
  <p>while looping through the options, I want to build an array that checks to see if keys exist, and if they don't they make the key then append the value. then the next loop through, if the key exists, add the next value, comma separated.</p>
  
  <p>the ideal output would be:</p>
  
  <pre><code>arr['context'] = 'cow,test,beans';
  arr['thing'] = '1,5,27';
  </code></pre>
  
  <p>here's what i have so far, but this isn't a good strategy to build the values..</p>
  
  <pre><code>function sift(select) {
          vals = [];
          $.each(select.options, function() {
              var valArr = this.value.split('|');
              var key = valArr[0];
              var val = valArr[1];
              if (typeof vals[key] === 'undefined') {
                  vals[key] = []; 
              }
              vals[key].push(val);
          });
          console.log(vals);
  }
  </code></pre>