title: What is the time complexity or Big O notation for "str.replace()" built In function in Javascript?
body: <p>I am confused if the time complexity for <code>str.replace()</code> function is O(n) or O(1), for example:  </p>
  
  <pre><code>var str = "Hello World";
  str = str.replace("Hello", "Hi");
  console.log(str);
  //===&gt; str = "Hi World"  
  </code></pre>
  
  <p>Is it always the same answer or does it depend on what we replace?<br>
  Any thoughts or helpful links?!</p>