title: Finding items that appear only one time in a Javascript array
body: <p>I'm trying to find the items that appear only one time in a Javascript array. In the following array:</p>
  
  <pre><code>['txfa2','txfa9','txfa2','txfa1','txfa3','txfa4','txfa8','txfa9','txfa2','txfa8']
  </code></pre>
  
  <p>The result should be:</p>
  
  <pre><code>['txfa1','txfa3','txfa4']
  </code></pre>
  
  <p>I'm currently using the <code>.each()</code> function in jQuery and <code>.sort()</code>. Is there a smarter or better way on doing this? Do you know of any jQuery plugin that can do this in fewer lines of code.</p>
  
  <pre><code>&lt;script src="../../js/jq.js"&gt;&lt;/script&gt;
  &lt;script&gt;
  var items = ['txfa2', 'txfa9', 'txfa2', 'txfa1', 'txfa3', 'txfa4', 'txfa8', 'txfa9', 'txfa2', 'txfa8'];
  var nopairs = []; //should contain only txfa1, txfa3, txfa4
  var haspair = '';//contains the item which has pairs
  var haspair_ctr = 0;
  var nopair_ctr = 0;
  
  var arranged = items.sort();
  
  $(arranged).each(function(index){
      if(index != arranged.length){
          if(arranged[index] != arranged[index + 1] &amp;&amp; arranged[index] != haspair){
              nopairs[nopair_ctr] = arranged[index];
              nopair_ctr++;
  
          }else{
              haspair  = arranged[index];
  
          }   
      }
  
  });
  console.log(nopairs);
  
  &lt;/script&gt;
  </code></pre>