call
call
Function
Dynamically call a function by function name or function value.
Syntax
call(fn_or_name, arg1, arg2, ...)
Parameters
| Parameters | Type | Required | Default value | Description |
|---|---|---|---|---|
| fn_or_name | String/Fn | Yes | None | Function name or function value. |
| argN | Any | No | None | Arguments passed to the target function. |
Return value
| Type | Description |
|---|---|
| Any | Returns the return value of the target function. |
Example
fn add(a, b) { a + b } result = call('add', 1, 2) // Output: 3 print result
Notes
- When calling by name, the user global function will be checked first, and then the system function will be checked.