87,996
社区成员




let ps = [
{
teacherName:'1',
students:['111','222']
},
{
teacherName:'2',
students:['333','444']
},
{
teacherName:'3',
students:['555','666']
}
];
//提取数组合并
Array.prototype.concat.apply([],ps.map(d=>d.students));
提取数组合并成一维数组,然后就能简单遍历了
let ps = [
{
teacherName:'1',
students:['111','222']
},
{
teacherName:'2',
students:['333','444']
},
{
teacherName:'3',
students:['555','666']
}
];
ps.forEach(function(v){
console.log("teacherName : " ,v.teacherName);
v.students.forEach(function(x){
console.log(x);
});
});