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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T13:12:51+00:00 2026-06-14T13:12:51+00:00

I don’t remember where, but I once saw it put that for..in loops can

  • 0

I don’t remember where, but I once saw it put that for..in loops can go through the elements in any order the implementors like, including forward, backward, randomly, or alternating between forward and back for each execution of a for..in loop. In practice, though, somehow I don’t think that the latter is really the case with any implementation in existence. (Although, there is a certain browser we know who likes to mess things up, so you can never be too sure, but I digress.)

My point is that while there probably isn’t such bad deviation in for..in sequencing in practice, I’d like to know what deviation, if any, there is between ECMAScript implementations. I suppose the main ones now would be JScript, Chakra, Futhark, Carakan, JavascriptCore, SquirrelFish, V8, SpiderMonkey, and TraceMonkey, just for reference.

  • 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-14T13:12:53+00:00Added an answer on June 14, 2026 at 1:12 pm

    First of all, here’s a reference from the specification with regard to the order of enumeration:

    12.6.4 The for-in Statement

    The mechanics and order of enumerating the properties (step 6.a in the first algorithm, step 7.a in the second) is not specified. Properties of the object being enumerated may be deleted during enumeration. If a property that has not yet been visited during enumeration is deleted, then it will not be visited. If new properties are added to the object being enumerated during enumeration, the newly added properties are not guaranteed to be visited in the active enumeration. A property name must not be visited more than once in any enumeration.

    The only ones I can think of off hand are these:

    • Earlier (maybe current?) versions of IE would place new properties that were added during enumeration to the end of the enumeration so that they would be visited by the current running for-in

    • V8 has a different order of enumeration as described in this bug report, which was closed as WorkingAsIntended

       var a = {"foo":"bar", "3": "3", "2":"2", "1":"1"};
      

      Testing in Firefox and V8 show a different order.

    This is not much of a list. There certainly may be more. I think it is summed up by @Pointy’s comment. There’s no guarantee. Even if you have an object that reliably enumerates in a consistent manner, this doesn’t mean that it will do so with the next version upgrade. Use tools for how they’re specified to work, not for what merely seems to work.

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

Sidebar

Related Questions

Don't ask why, but is there any way to suppress a failed linking error?
Don't shoot me, but it's the first time I saw a usage of a
(Don't know if this is strictly on-topic, but I don't see any better Stack
Don't ask me why but i can't use this method because I need to
Don't know why but I can't find a solution to this. I have 3
DON'T ASK WHY but... I have a regex that needs to be case insensitive
don't know if the title describes anything about what I'm trying to say but
Don't ask me how but I'm in a situation where I have DCPs published
Don't really know how to formulate the title, but it should be pretty obvious
Don't know how to google for such, but is there a way to query

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.