title: get all combinations for a string
body: <p>I'm trying to create a function in JavaScript that given a string will return an array of all possible combinations of the letters with each used at most once, starting with the shortest. e.g for the string ABC it would return:</p>
  
  <pre><code>A
  B
  C
  AB
  AC
  ABC
  </code></pre>
  
  <p>I could use loops like so:</p>
  
  <pre><code>for(i=0; i&lt;string.length; i++) {
     //add string[i]
  }
  for(i=0; i&lt;string.length; i++) {
      for(a=i; a&lt;string.length; a++) {
              //add string[i]+string[a]
      }
  }
  for(i=0; i&lt;string.length; i++) {
      for(a=i; a&lt;string.length; a++) {
          for(b=a; b&lt;string.length; b++) {
              //add string[i]+string[a]+string[b]
          }
      }
  }
  </code></pre>
  
  <p>But I don't know the length of the string, so wouldn't know how many loops to use.</p>
  
  <p>Any ideas?</p>
  
  <p>Edit: I'm not asking for permutations, abc and acb shouldn't both be returned. Also the shortest being first in the array is important.</p>
  
  <p>This is not homework. It's for a program to solve a 'lights-out' type game.</p>