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

The Archive Base Latest Questions

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

I have this object in JS: var list = {134 : A,140 : B,131

  • 0

I have this object in JS:

var list = {134 : "A",140 : "B",131 : "C"}

I run it with:

jQuery.each(list, function(key, value) { 
console.log(key + " - " + value);
});

The output should be:

134 - A
140 - B
131 - C

But I dont know why, the output is:

131 - C
134 - A
140 - B

Any idea how can I fix it ?

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

    First off: that’s not a list, it’s an object. Object’s order is not guaranteed to be kept – each implementation may choose a different ordering.

    On the other hand, arrays do preserve order:

    var list = [[134, "A"],[140, "B"],[131, "C"]];
    
    
    jQuery.each(list, function(i, obj) { 
      console.log(i + " - " + obj[0] + " - " + obj[1]);
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I currently have this: $.getJSON('test.json', function(data) { var items = []; $.each(data, function(key, val)
I have an object: var seriesOptions = { y: parseFloat($(this).find('y').text()).toFixed(2), color: colors[index], level :
I have the following object: var r = { obj: $(this), children: $(this).children(), panes:
I have a javascript that does this (http is your XMLHttpRequest object) var r
Currently I have this code var App = Ember.Application.create(); App.user = Ember.Object.create({ people: customers
I have a LINQ query that returns some object like this... var query =
I have this: <%foreach (var item in (List<MyClass>)ViewData[something]) {%> and it throws exception: Unable
I have a Problem accessing an Object function using this. In case of the
Hy, I have this c# code: var criteria = GetSession().CreateCriteria<Indicatore>(); List<string> dpsirs //passed as
I have a list of this object: public class Customer { public int Id

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.