name: duk_opt_context proto: | duk_context *duk_opt_context(duk_context *ctx, duk_idx_t idx, duk_context *def_value); stack: | [ ... val! ... ] summary: |

Get a context pointer for a Duktape thread at idx. If the value is undefined or the index is invalid, def_value default value is returned. In other cases (null or non-matching type) throws an error.

example: | duk_context *target_ctx; target_ctx = duk_opt_context(ctx, 2, default_ctx); tags: - stack - borrowed introduced: 2.1.0