title: How can I extend the document object?
body: <p>I'm currently trying to get a better understanding of JavaScript and prototyping.</p>
  
  <p>I wanted to add a function to the <code>document</code> but <code>prototype</code> is undefined on <code>document</code>.</p>
  
  <p>This code:</p>
  
  <pre><code>document.prototype.writeLine = function(text){
      this.write(text);
      this.write("&lt;br /&gt;");  
  };
  </code></pre>
  
  <p>Generates this error:</p>
  
  <pre><code>// In FireFox
  TypeError: document.prototype is undefined
  
  // In Chrome
  Uncaught TypeError: Cannot set property 'writeLine' of undefined 
  </code></pre>
  
  <p>How can I extend the <code>document</code> object to be able to call something similar to <code>document.WriteLine('MyText')</code> ?</p>
  
  <p>Here is the <a href="http://jsfiddle.net/qpZ6K/" rel="nofollow"><strong>Fiddle</strong></a> I'm working with.</p>