title: 'indexOf' method performance optimization
body: <p>According to <a href="https://stackoverflow.com/questions/518000/is-javascript-a-pass-by-reference-or-pass-by-value-language">Is JavaScript a pass-by-reference or pass-by-value language?</a> JavaScript passes string objects by value. Because of that, calling the <code>indexOf</code> method will trigger copying the content.</p>
  
  <p>In my case, I am parsing a big string to look for data. I heavily use <code>indexOf</code> to find data. String can big as long as 100-200KB and I could need to call <code>indexOf</code> up to 1000 times per full scan.</p>
  
  <p>I'm afraid this will cause polluting 'memory' with unnecessarily copied string and could impact performance.</p>
  
  <p>Am I correct in my conclusion? If so, what is the proper way to deal with my task?</p>
  
  <p>Potentially, I could use regular expressions, but at the moment that looks <em>too</em> complex.</p>