A loop that keeps incrementing until the variable is smaller that the length of the child nodes keeps crashing my page. Why?

I have this very simple loop that keeps crushing my page.

var listtest = document.getElementById("newlist");

for(var t = 0; t < listtest.childNodes.length; t++) { 
  var crash = document.createElement("a");
  var crashtext = document.createTextNode("some random text"+t);
  crash.appendChild(crashtext);
  listtest.insertBefore(crash, listtest.childNodes[t]);
}
<ul id="newlist">
  <li>First</li>
  <li>Second</li>
  <li>Third</li>
</ul>

Every time I run this loop, my page crashes. I can’t even open the console. I know the issue has to be with the condition t < childNodes.length, because when I remove it, it doesn’t crash, but I can’t figure out what exactly is the problem with my condition, or code in general?

178 thoughts on “A loop that keeps incrementing until the variable is smaller that the length of the child nodes keeps crashing my page. Why?”

  1. Hi there, just became aware of your blog through Google, and found that it’s truly
    informative. I am gonna watch out for brussels.
    I will appreciate if you continue this {in future}.
    Lots of people will be benefited from your writing.
    Cheers!

    Reply
  2. wonderful submit, very informative. I’m wondering why the other specialists of this sector do not notice this.
    You should proceed your writing. I am confident, you’ve a great
    readers’ base already!

    Reply
  3. I don’t know whether it’s just me or if perhaps everybody else experiencing issues with your blog.
    It appears as though some of the written text in your content are running off the screen. Can someone else please comment and let me
    know if this is happening to them as well? This could be a
    problem with my browser because I’ve had this happen before.
    Many thanks

    Reply
  4. Heya i’m for the first time here. I came across this board
    and I find It really useful & it helped me
    out much. I hope to present something again and aid others like you helped me.

    Reply
  5. I was pretty pleased to discover this website. I need to to thank you for your time due to this wonderful read!!
    I definitely enjoyed every bit of it and I have you book marked to see
    new things in your website.

    Reply
  6. It’s appropriate time to make some plans for the long run and it’s time to be happy.

    I have read this post and if I may just I wish to counsel you some interesting things or
    suggestions. Perhaps you could write subsequent articles relating to this article.
    I wish to learn even more issues about it!

    Reply
  7. Just desire to say your article is as surprising. The clearness in your post is simply cool and i
    could assume you’re an expert on this subject. Fine with your permission let me to grab your RSS feed to keep updated with forthcoming post.
    Thanks a million and please continue the rewarding work.

    Reply
  8. It’s actually a cool and useful piece of information. I’m happy that you simply shared this useful information with us.
    Please stay us informed like this. Thanks for sharing.

    Reply
  9. I think this is among the most important info for me.

    And i am glad reading your article. But should remark on few general things, The website style
    is ideal, the articles is really excellent : D. Good
    job, cheers

    Reply
  10. I was curious if you ever considered changing the page layout of your blog?
    Its very well written; I love what youve got
    to say. But maybe you could a little more in the way of content so people
    could connect with it better. Youve got an awful
    lot of text for only having 1 or 2 images. Maybe you
    could space it out better?

    Reply
  11. Undeniably believe that which you stated. Your favorite justification appeared to be on the web the simplest thing to be aware of.

    I say to you, I definitely get irked while people consider worries that they just don’t
    know about. You managed to hit the nail upon the
    top and also defined out the whole thing without having side-effects , people could take a signal.
    Will probably be back to get more. Thanks

    Reply
  12. hi!,I really like your writing very so much!

    percentage we be in contact more about your post on AOL?
    I require an expert on this area to resolve my
    problem. Maybe that’s you! Taking a look forward to peer you.

    Reply
  13. Hello, Neat post. There is a problem with your web site in web explorer, could test this?

    IE still is the marketplace chief and a huge component of other people will leave out your wonderful writing due
    to this problem.

    Reply
  14. Hey would you mind letting me know which webhost you’re utilizing?
    I’ve loaded your blog in 3 different internet browsers and I must say this blog
    loads a lot quicker then most. Can you suggest a good hosting
    provider at a fair price? Thanks, I appreciate it!

    Reply
  15. Thanks for finally writing about > A loop that keeps incrementing until the variable is smaller that the length of the child nodes keeps crashing my page.
    Why? – JavaScript Help < Loved it!

    Reply
  16. Today, I went to the beachfront with my children. I found a sea shell and gave it to my 4
    year old daughter and said “You can hear the ocean if you put this to your ear.” She put the shell to
    her ear and screamed. There was a hermit crab inside
    and it pinched her ear. She never wants to go back! LoL I know this is totally off topic
    but I had to tell someone!

    Reply
  17. Have you ever considered about including a little bit more than just your articles?
    I mean, what you say is valuable and all. But think
    of if you added some great pictures or video clips to
    give your posts more, “pop”! Your content is excellent
    but with images and clips, this website could undeniably be one
    of the best in its field. Good blog!

    Reply
  18. Thanks for some other magnificent post. Where else could anybody get that type of info in such an ideal manner of writing?
    I’ve a presentation subsequent week, and I’m at the search for such information.

    Reply
  19. Thank you a lot for sharing this with all folks you really
    understand what you are talking about! Bookmarked.

    Please additionally consult with my web site =). We can have a hyperlink alternate agreement between us

    Reply
  20. We stumbled over here coming from a different web page and
    thought I should check things out. I like what I see so i am just following you.
    Look forward to looking into your web page again.

    Reply
  21. Hello! This is my first visit to your blog! We are a
    team of volunteers and starting a new project in a
    community in the same niche. Your blog provided us beneficial information to work
    on. You have done a outstanding job!

    Reply
  22. I’m not sure where you’re getting your info, however good topic.
    I needs to spend some time studying more or working out more.
    Thanks for magnificent info I was looking for this info for
    my mission.

    Reply
  23. Howdy, I think your blog may be having browser compatibility problems.
    When I take a look at your website in Safari, it looks fine however, if opening in I.E., it’s got some overlapping
    issues. I merely wanted to give you a quick heads up!
    Aside from that, excellent site!

    Reply
  24. Hello there! This is kind of off topic but I need some advice from an established blog.
    Is it difficult to set up your own blog? I’m not very techincal
    but I can figure things out pretty fast. I’m thinking about setting up my own but I’m not sure where to begin. Do you have
    any points or suggestions? Appreciate it

    Reply
  25. What’s up it’s me, I am also visiting this website daily, this site is truly pleasant and the viewers are really sharing nice thoughts.

    Reply
  26. Hi, Neat post. There’s a problem along with your website in web explorer, might
    test this? IE still is the market leader and a huge element of people will
    leave out your magnificent writing because of this problem.

    Reply
  27. Does your blog have a contact page? I’m having problems locating it but, I’d like to shoot
    you an email. I’ve got some recommendations for your blog you
    might be interested in hearing. Either way, great site and I look forward to seeing it improve over time.

    Review my website :: login poker pulsa

    Reply
  28. Very good blog! Do you have any recommendations for aspiring writers?
    I’m planning to start my own site soon but I’m a little lost on everything.
    Would you propose starting with a free platform like WordPress or go for
    a paid option? There are so many choices out
    there that I’m totally confused .. Any recommendations?
    Thank you!

    Reply
  29. Hi! I could have sworn I’ve visited this blog before but after looking at many of
    the articles I realized it’s new to me. Anyways, I’m definitely happy I
    came across it and I’ll be bookmarking it and checking back frequently!

    Reply
  30. Pretty section of content. I just stumbled upon your weblog and in accession capital to assert that I get
    in fact enjoyed account your blog posts. Any way I’ll be subscribing to
    your feeds and even I achievement you access consistently rapidly.

    Reply
  31. Wonderful items from you, man. I’ve consider your stuff prior to
    and you’re just too wonderful. I actually like what you’ve bought here, really
    like what you are stating and the way in which during which you
    say it. You are making it enjoyable and you still care for to keep it smart.
    I cant wait to read far more from you. This is really a terrific website.

    Reply
  32. I do not even know how I ended up here, but I thought
    this post was great. I don’t know who you are but certainly you’re going to a
    famous blogger if you aren’t already 😉 Cheers!

    Reply
  33. An outstanding share! I have just forwarded this
    onto a co-worker who has been conducting a little homework on this.
    And he in fact ordered me breakfast due to the fact that I found it for him…
    lol. So let me reword this…. Thank YOU for the meal!! But yeah, thanks for spending time to
    discuss this matter here on your website.

    Reply
  34. When I originally commented I clicked the “Notify me when new comments are added” checkbox and now each time a comment
    is added I get several emails with the same comment.
    Is there any way you can remove me from that service?
    Thank you!

    Reply
  35. Today, while I was at work, my cousin stole my iphone and tested to see if it
    can survive a twenty five foot drop, just so she can be a youtube sensation. My iPad is now broken and she
    has 83 views. I know this is totally off topic but I had to share it
    with someone!

    Reply

Leave a Comment