title: Get an array of matches in string as indexes
body: <p>Example: "abc abc ab a".indexOfList("abc") returns [0,4]</p>
  
  <p>My code: </p>
  
  <pre><code>String.prototype.indexOfList=function(word){
      var l=[];
      for(var i=0;i&lt;this.length;i++){ //For each character
          var pushed=(this[i]==word[0])&amp;&amp;(word.length+i&lt;=this.length);
          if (pushed) {
              for(var j=1;j&lt;word.length;j++){
                  if (word[j]!=this[i+j]) {
                      pushed=false; break;
                  }
              }
          }
          if (pushed) {
              l.push(i);
          }
      }
      return l;
  }
  </code></pre>
  
  <p>Is there a better and smaller way than this?</p>