title: What does document.write() do?
body: <p>This is a very basic question.
  I have this script: </p>
  
  <pre><code>    &lt;script type="text/javascript"&gt;
          function write(){
              document.write('Hello2')
          }
          write();
      &lt;/script&gt;
  </code></pre>
  
  <p>It shows my complete page. And at the end of page <strong>Hello2</strong> will be displayed.
  But when ever I go to developer tools and call <strong>write()</strong>, it will replace my entire body html. Just curious to know.</p>
  
  <pre><code>        window.onload=write;// has the same effect. Clear's my page.
  </code></pre>
  
  <p>Thanks.</p>