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

  • Home
  • SEARCH
  • 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 9189329
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T20:12:42+00:00 2026-06-17T20:12:42+00:00

If I attach an additional property to an object, does it have to go

  • 0

If I attach an additional property to an object, does it have to go at the end, or can I put it at a specified position.

function reassign(obj){
  delete obj.c;
  obj.c = "new three";

  var t = "<table border=\"1\">";
  for (var i in obj){
    t += "<tr><td>" + obj[i] + "</td></tr>"; 
  }
  t += "</table>";
  return t;
}

var obj = {
  a : "one",
  b : "two",
  c : "three",
  d : "four" 
};

var reassigned = reassign(obj);
document.write(reassigned);

Would it be possible somehow to put the new obj.c in the third position again after it’s been deleted, rather than having it appended to the end? Of course I could skip the delete part. But even without that, I could also for example intend inject alphabeta: "one point five" into the second position. Is it possible? Thanks!

jsbin

  • 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-17T20:12:43+00:00Added an answer on June 17, 2026 at 8:12 pm

    Array elements are ordered; object properties are not. You should never assume that object properties will be iterated in a particular order.

    If order is important to you, create a new order:[] property which contains an array of property names, and you can iterate through that:

    var obj = {
      a : "one",
      b : "two",
      c : "three",
      d : "four",
      order : ['a','b','c','d']
    };
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

If I have the following ListView , how can I attach a SelectedIndexChanged event
How can I attach additional information to a button programmatically? I can mButton.setText(new text)
I found this article useful when indexing documents, however, how can I attach additional
I have a column for images. I would like to attach some additional text
I would like to create a jQuery function that I can attach to form
I have question regarding how to attach additional form to logged in users in
I want to attach image with attributes for example i have manufacture attribute and
If I attach an image to an email, how can I place it in
Basically I looking for the ability to attach methods to an executable function while
I have an object handed into our library and passed through various processes. I

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.