Why does these codes crush when i don't use var theLength in for loop? Why do i need to assign x.length to var theLength and use it in for loop to make it work? thanks, *nothing wrong with my question, stop putting my question on hold. someone is trying to learn.
  <html>
        <head>
            <script>
                window.onload= test;
                function test(){
                    var x=document.getElementsByTagName('*');
                    var theLength=x.length;
                    for(var i=0; i<x.length; i++){ // this i<x.length won't work
                                                 // But it will work with i<theLength
                        document.write("Hello World!<br>");
                    }
                }
            </script>
        </head>
        <body>  
        </body>
    </html>
 
     
     
     
    