I have an instance (let's refer to it as myObject) that is structured like this (when you log it to the console):
>Object {info1: Object, info2: Object, info3: Object, info4: Object,…}
>info1: Object
>info2: Object
Id: 532
someParam: true
>info3: Object
>info4: Object
Id_secondary: 222
Upon inspecting the contents of info1 and info2 (nested objects within the main object), their layout appears as follows:
Aparameter: "random info"
Cparameter: "something"
LParameter: "other data"
Surname: "Random Surname"
Username: "Name test"
What I find troubling is that they are arranged in alphabetical order.
When I attempt to iterate through this specific object, I notice that the data within info1 and info2 (objects inside the main object) are not arranged alphabetically. I confirm this by executing:
for (var k in myObject)
if (typeof myObject[k] !== 'function') {
if(k == 'info1' || k == 'info2' || k == 'info3' || k == 'info4'){
for (var j in myObject[k]){
if (typeof myObject[k][j] !== 'function' && k == 'info1') {
console.log("Key is " + j + ", value is " + myObject[k][j]);
}
}
// HERE the data of these objects are in the correct order!
console.log(myObject[k]); <------------------------- observe this
}
}
}
Is there a way to maintain the sequence of the data inside the objects in myObject?
Any assistance would be greatly appreciated