name: duk_has_prop_index proto: | duk_bool_t duk_has_prop_index(duk_context *ctx, duk_idx_t obj_idx, duk_uarridx_t arr_idx); stack: | [ ... obj! ... ] -> [ ... obj! ... ] summary: |

Like duk_has_prop(), but the property name is given as an unsigned integer arr_idx. This is especially useful for checking existence of array elements (but is not limited to that).

Conceptually the number is coerced to a string for property existence check, e.g. 123 would be equivalent to a property name "123". Duktape avoids an explicit coercion whenever possible.

example: | if (duk_has_prop_index(ctx, -3, 123)) { printf("obj has index 123\n"); } else { printf("obj does not have index 123\n"); } tags: - property introduced: 1.0.0