Uncaught TypeError: Object [object DOMWindow] has no method 'replace'
<p>I'm studying javascript. I just want to understand why the strip2() function in the below code doesn't work, and returns an error.</p>

<pre><code>&lt;script type="text/javascript"&gt;
function strip1(str) {
  return str.replace(/^\s+|\s+$/g, "")
};
function strip2() {
  return this.replace(/^\s+|\s+$/g, "")
};

var text = ' Hello  ';
console.log(strip1(text));  // Hello
console.log(strip2(text));  // Uncaught TypeError: Object [object DOMWindow] has no method 'replace'
&lt;/script&gt;
</code></pre>

<p>Thanks.</p>
