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 8741235
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T11:16:32+00:00 2026-06-13T11:16:32+00:00

While testing some JavaScrpt code in IE8 I’m experiencing some strange behaviour when doing

  • 0

While testing some JavaScrpt code in IE8 I’m experiencing some strange behaviour when doing a simple for..in loop:

var categories = ['for', 'bar', 'steam'];
for(var key in categories) {
    console.log(key);
}

Outputs:

0
1
2
forEach
map
filter
reduce
indexOf
end

Which includes the Array prototype functions, right? That’s definitely not the way it should work. Why is that?

Btw, it works of course when changing the loop to for (var key=0; key < categories.length, key++).

  • 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-13T11:16:33+00:00Added an answer on June 13, 2026 at 11:16 am

    That’s because you are probably using a library that extends Array.prototype. The reason it doesn’t happen in other browsers is that they already support those methods natively. Since IE doesn’t support it, there’s some code that adds it in JS, which makes the methods enumerable.

    That’s one of the reasons why you shouldn’t use for in with arrays.

    The other is the fact that for in does not guarantee order of iteration, and though it does work in most browsers, it’s explicitly left as undefined behavior by the specification. John Resig himself filed a bug against chrome http://code.google.com/p/chromium/issues/detail?id=883 and it was closed as won’t fix, since there’s no requirement that properties need to be ordered

    Stick to using a standard loop

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've been testing some stuff with Google maps, and while this code gives me
I was testing some HTML code I'm making, and while using the Developer Tools
My time zone is CET (Berlin). And while testing Joda's DateTime i noticed some
This foreach loop works fine while testing and only returning 5 rows of data,
I am trying to learn and writting this part of code. while testing few
While doing performance testing on windows, i usually use perfmon. But when i put
I get this error, while I'm testing the code below: You have an error
I am having problems with code written in ASP.NET with some javascript, doing a
I'm doing some Javascript R&D and, while I've read Javascript: The Definitive Guide and
I am testing some weird-looking CSS code that I wrote (I'm using a mix

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.