我收到一个错误,例如
减少没有初始值的空数组
何时执行以下操作:
var fields = $(".invoiceli");
$(document).delegate(fields, 'change', function() {
Array.prototype.reduce.call(fields, function(prev, curr)
//.....
});
})
有人可以指出我正确的方向吗?
谢谢!
reduce 函数需要非空数组或初始值作为参数。
试试这个
Array.prototype.reduce.call(fields, function (prev, curr) ..... }, null);