我正在尝试打印y中的对象名称有其键值但是出错。 请帮帮我......
这是我的java脚本代码
this.data
答案 0 :(得分:0)
var object = {
name: "venu",
id: 99,
age: 100,
"x": [
"balaji",
22,
11
],
/*>>>not inside the x>>>*/ "y": {
name: "balu",
id: 55,
age: 22
}
};
var g = object.x;
for (var i = 0; i < g.length; i++) {
for (var k = 0; k < g[i].y.length; k++) { //object.x.y.length is undefined as y is not something in x
console.log(g[i].y.name);
}
}