=proto void duk_call_prop(duk_context *ctx, int obj_index, int nargs); =stack [ ... obj! ... key! arg1! ...! argN! ] -> [ ... obj! ... retval! ] =summary
Call obj.key
with nargs
arguments, with this
binding set to obj
. The property name and the function arguments
are replaced by a single return value; the target object is not touched.
An error during the function call is not automatically caught.
If the target function is not strict, the binding value seen by the target function may be modified by processing specified in Entering Function Code.
This API call is equivalent to:
var retval = obj[key](arg1, ..., argN);
or:
var func = obj[key]; var retval = func.call(obj, arg1, ..., argN);=example /* obj.myAdderMethod(2,3) -> 5 */ int obj_idx; duk_push_string(ctx, "myAdderMethod"); duk_push_int(ctx, 2); duk_push_int(ctx, 3); duk_call_prop(ctx, obj_idx, 2); /* [ ... "myAdderMethod" 2 3 ] -> [ ... 5 ] */ printf("2+3=%d\n", duk_get_int(ctx, -1)); duk_pop(ctx); =tags property call