javascript遍历的相关问题
varo=[{a:"111",b:"222"},{c:"333",d:"444"}];varbody=o.map(function(obj){Object.keys(ob...
var o =[{a:"111",b:"222"},{c:"333",d:"444"}];
var body = o.map(function(obj){
Object.keys(obj).map(function(attr){
console.log(obj[attr]);
return (obj[attr]);
});
}
);
console.log(body);
//以下是输出:
"111"
"222"
"333"
"444"
[undefined, undefined]
问题:body为什么是underfined???? 如果要正确输出body,该怎么做???? 展开
var body = o.map(function(obj){
Object.keys(obj).map(function(attr){
console.log(obj[attr]);
return (obj[attr]);
});
}
);
console.log(body);
//以下是输出:
"111"
"222"
"333"
"444"
[undefined, undefined]
问题:body为什么是underfined???? 如果要正确输出body,该怎么做???? 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询