Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8235899
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T18:58:22+00:00 2026-06-07T18:58:22+00:00

I am using a for-in loop to iterate over an array of two elements,

  • 0

I am using a for-in loop to iterate over an array of two elements, but it is like its looping twice.

I have an example here: http://jsbin.com/etoyac/8/

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T18:58:25+00:00Added an answer on June 7, 2026 at 6:58 pm

    It’s because the result returned from getElementsByTagName isn’t a simple array — it’s a NodeList and it’s “live”. Updates you make to the DOM are reflected in the list immediately.

    You can use the “slice” method on the Array prototype to turn the NodeList into an array:

    var slideArr = [].slice.call(slides, 0);
    

    Also you should iterate through the array (or the NodeList for that matter) with a numeric index:

    for (var slideIndex = 0; slideIndex < slideArr.length; ++slideIndex) {
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Since now, I'm using this loop to iterate over the elements of an array,
I need to iterate over all elements in array in VBScript, but it's dimensions
How can I skip over a loop using pdb.set_trace() ? For example, pdb.set_trace() for
If there is a method call MyClass.returnArray() and I iterate over the array using
In Twig I am trying to iterate over a potentially incomplete array using a
I'm using a for loop to iterate over persisted form objects on validation and
I am using a foreach loop in SSIS to iterate over the contents of
In my code I have for loop that indexes over a multidimensional numpy array
I have a BOOST_FOREACH loop to iterate over a list. Unfortunately, I also need
How can I iterate over each file in a directory using a for loop?

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.