javascript - Save the order in Object while inserting numerical keys -


I am parsing a XML and I am making an object with those values Pass Pars is the parseXmlByTag () function that parses with specific TAG - its work is good, so consider returning it to what she should return.

  this.mytempect = {}; (Var i = 0; i & lt; xml.length; i ++) for {var temp = {}; Temp.ID = parseXmlByTag (xml [i], "id"); Temp.name = parseXmlByTag (xml [i], "name"); Temp.phone = parseXmlByTag (xml [i], "phone"); If (this.mytempect [temp.ID] == tap) this.mytempect [temp.ID] = []; This.mytempect [temp.ID] .push (temporary); }  

Before saving each object, I check that I need to create a new key for it or add it to the current, It gets:

  object {56: array [1], 70: array [1], 78: array [3]}  

but first One was with ID 78 and the second one was with ID 70 . When I use .push () , its its id numerical number - if it is larger than the latter, then before that.

I have to save the order in which I am receiving them, so I will save them in the order in which order (Order [1], 70: Array [1], 56: Array [ 3]} How can anyone correct any thoughts?

< P> Hashmaps languages ​​in javascript in the other, if you are familiar with them - in other words, the data is kept in key-value pairs, but an order is specially Therefore, you can not rely on the member variable of the object, because they will not.

You have to use the data structure that does order is protected , Like array.


Comments

Popular posts from this blog

java - org.apache.http.ProtocolException: Target host is not specified -

java - Gradle dependencies: compile project by relative path -

ruby on rails - Object doesn't support #inspect when used with .include -