我想知道是否存在将回调函数的所有参数存储到数组中的方法?我能否知道回调函数的参数数量?
例如
一些回调函数将接收2个参数错误和行。我可以将它们存储到数组中吗?
c.query('SHOW DATABASES', function(err, rows) {
if (err)
throw err;
console.dir(rows);
});
感谢
答案 0 :(得分:1)
function foo(){
var args = Array.prototype.slice.call(arguments);
console.log(arguments.length);
console.log(args);
}
foo(1,2,3,'a',true);
答案 1 :(得分:1)