Defining Javascript function with prototype property
<p>What's wrong with this piece of code?</p>

<pre><code>(function (){
    'use strict';

    // add hasClass function
   String.prototype.hasClass = function (className) {
       return this.className.search('(\\s|^)' + className + '(\\s|$)') != -1 ? true : false;
   };

   console.log(document.getElementById('link').hasClass('test'));    
})();
</code></pre>

<p>I'd expect it to return <code>true</code> or <code>false</code>, but all I get is</p>

<pre><code>TypeError: document.getElementById("link").hasClass is not a function**
</code></pre>

<p><strong>UPD:</strong> Thanks guys. Now i get it. I should set method to Object or Element (What is more right?) not String!</p>
