【发布时间】:2017-01-11 21:54:12
【问题描述】:
function PersonAMK(vn, ln) {
this.nachname = ln;
this.vn = vn;
this.marks = [];
this.marks.push([4, 67, 5]);
this.marks.push([41, 63, 5]);
this.marks.push([4, 67, 55]);
}
var peprson = new PersonAMK('Unknwon', 'Unknown');
peprson.marks.forEach(function callBack(arrSch1, arrSch2) {
arrSch1.forEach(function callBack(nod1) {
console.log(nod1);
});
arrSch2.forEach(function callBack(nod1) {
console.log(nod1);
});
});
我收到错误:arrSch2.forEach 不是函数
我实际上不明白为什么 arrSch2.forEach 不起作用。的第二个值不是标记了一个值为 [41,63,5]; 的数组吗?
【问题讨论】:
-
您不需要
arrSch2.forEach(),您已经在使用peprson.marks.forEach()和arrSch1.forEach()循环枚举二维数组。
标签: javascript arrays printing foreach