gpt4 book ai didi

javascript - 如何将参数传递给函数?

转载 作者:行者123 更新时间:2023-11-29 22:27:49 25 4
gpt4 key购买 nike

我在 nodejs 中有以下函数,res.execSync 接受多个参数,详见此处: https://github.com/xdenser/node-firebird-libfbclient

function execSync(param1, param2, ..., paramN);
param1, param2, ..., paramN - parameters of prepared statement in the same order as in SQL and with appropriate types.

function test(sql, callback)
{
var args = Array.prototype.slice.call(arguments).splice(2);
res.execSync(args);
}

test('test', function() {}, "param1", "param2", "param3");

错误:期望字符串作为参数 #1。

我该如何解决?

最佳答案

你不是说:

function test(sql, callback)
{
var args = Array.prototype.slice.call(arguments, 2);
res.execSync.apply(res, args);
}

test('test', function() {}, "param1", "param2", "param3");

关于javascript - 如何将参数传递给函数?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8483108/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com