In JS a function's length is the number of parameters a function takes excluding the rest parameter.
function x(a, b, c) {}
x.length; // 3
function y(...rest) {}
y.length; // 0
Same rules apply to Lua's nparams.
function x(a, b, c) end
debug.getinfo(x).nparams -- 3
function y(...) end
debug.getinfo(y).nparams -- 0
debug.getinfo(a).nparams seems to be usable in all supported Lua environments except for 5.1.
Lua 5.3 ✔
Lua 5.2 ✔
LuaJIT ✔
Lua 5.1 ❌
In JS a function's length is the number of parameters a function takes excluding the rest parameter.
Same rules apply to Lua's nparams.
debug.getinfo(a).nparamsseems to be usable in all supported Lua environments except for 5.1.Lua 5.3 ✔
Lua 5.2 ✔
LuaJIT ✔
Lua 5.1 ❌