Get the number of arguments a function expects.

Syntax

uint16_t
JS_GetFunctionArity(JSFunction *fun);
Name Type Description
fun JSFunction * A JavaScript function.

Description

JS_GetFunctionArity returns the number of formal parameters of a function, fun. This is the same as the function object's arity property, if that property has not been overwritten. Specifically, if fun is a native function, the result is the value that was passed to the nargs parameter of JS_DefineFunction. Otherwise fun is implemented in JavaScript, and the result is the number of identifiers in its formal parameter list (see ECMA 262-3 ยง13).

Note that it is not an error per se to call a JavaScript function with more or fewer actual arguments than its arity.

See Also