download.file(URL="", destfile="",mode='wb')
我收到错误:arrSch2.forEach不是函数
我实际上并不理解为什么arrSch2.forEach不起作用。不是标记数组的第二个值,值为[41,63,5];?
答案 0 :(得分:0)
传递给forEach
的第二个参数是index
。所以,arrSch2
实际上只是一个数字。数字上不存在forEach
方法。
这是一个不同的观点:
peprson.marks.forEach(function callBack(arrSch1, index) {
...
}
答案 1 :(得分:0)
Array.prototype.forEach回调函数有三个参数:
arrSch2是一个不是数组的数字。
将您的代码更改为此 - 我删除了第二个forEach调用:
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) {
arrSch1.forEach(function callBack(nod1) {
console.log(nod1);
});
});

答案 2 :(得分:0)
数组的第二个元素是[41,63,5],但这不是你的参数中传递的内容。如果您只想迭代数组,那么类似下面的内容将起作用:
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 (arr) {
arr.forEach(function (nod1) {
console.log(nod1);
});
});
答案 3 :(得分:0)
为什么不使用简单的循环。
select case
when grouping(country) = 1 then 'Total'
else country
end as country,
count(*)
from customer
group by rollup (country )
试试这个。使用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');
for (i = 0; i < peprson.marks.length; i++) {
for (j = 0; j < peprson.marks[i].length; j++){
console.log(peprson.marks[i][j]);
}
}
方法。为此提供以下输出:JSON.stringify()
。您需要迭代{"nachname":"Unknown","vn":"Unknwon","marks":[[4,67,5],[41,63,5],[4,67,55]]}
记住peprson.marks
包含每个索引上的数组。祝你好运!!