I have a variable that contains 4 objects which I can view when logging it out in the console. However, I am struggling to create the desired structure for this return variable (I want to sort it but need to first recreate the structure).
When I check the original variable in the console, it shows: [Object, Object, Object, Object]
But with the created variable, I only get: [Object]
Below is my attempt to re-create it:
this.obj = [{items:[{code:'bravo',color:'blue',date:'2017-01-01',pos:'up'},
{code:'alpha',color:'blue',date:'2017-01-02',pos:'down'}],
color:'blue'}],
[{items:[{code:'bravo',color:'blue',date:'2017-01-01',pos:'up'},
{code:'alpha',color:'blue',date:'2017-01-02',pos:'down'}],
color:'green'}],
[{items:[{code:'bravo',color:'blue',date:'2017-01-01',pos:'up'},
{code:'alpha',color:'blue',date:'2017-01-02',pos:'down'}],
color:'red'}],
[{items:[{code:'bravo',color:'blue',date:'2017-01-01',pos:'up'},
{code:'alpha',color:'blue',date:'2017-01-02',pos:'down'}],
color:'yellow'}]
;
The first objects in both original and created are the same, but why can't it recognize the other three objects? If I add two additional square brackets around my code, all four are recognized, but then they are changed into arrays instead of objects...