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?
You have to use the data structure that does order is protected , Like array.
Comments
Post a Comment