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

Get the number at idx and convert it to a C duk_uint_t by first clamping the value between [0, DUK_UINT_MAX] and then truncating towards zero. The value on the stack is not modified. 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: | unsigned int count = (unsigned int) duk_opt_uint(ctx, 1, 3); /* default: 3 */ tags: - stack introduced: 2.1.0