How JS iterates through properties in an object

var a = {

b: [1,2,3,4],
c: [3,4,5,65],
...
...

}
for example, object a
I want to iteratively get the value in bbr c in object a, how to get
the real problem is more complicated, this is just a simple example
Sorry, maybe my example is too simple
to give a new example

var a = {

    b: [{name:"anni",isshow:false},    
      {name:"ansdfsni",isshow:false}],
    c: [{name:"123",isshow:false},{name:"345",isshow:false},                    
        {name:"546",isshow:true},{name:"789",isshow:true}]
The

}
problem is solved, regardless of whether the an object gets the property in the form of an array (I don"t know if this description is correct), but it is still an array in the attribute value of the object, so it is a two-dimensional array, so everything is very clear, thank you for your answer!

May.22,2021

    let a = {
        b: [1,2,3],
        c: [4,5,6,7]
    }
    let newlist = [];
    for(var k in a){
        a[k].forEach((e)=>{
            // 
            newlist.push(e)
        })
    }
    console.log("newlist:", newlist);

you can do whatever you want in forEach.


   let a = {
            b: [1,2,3],
            c: [4,5,6,7]
    }
    for(var i in a){
        console.log(a[i])
    }


var a={
    b:[1,2,3,4],
    c:[3,4,5,6]
};
var arr=[];
for(var i=0;i<a.b.length;iPP){
    arr.push(a.b[i])
}
console.log(arr)

generally, the foreground page acquires the background data in the same way.
create an empty array and push the data into the array when traversing.

Menu