=proto unsigned int duk_to_uint16(duk_context *ctx, int index); =stack [ ... val! ... ] -> [ ... ToUint16(val)! ... ] =summary

Replace the value at index with an Ecmascript ToUint16() coerced value. Returns the coerced value. If index is invalid, throws an error.

Custom type coercion:

The result of ToUint16() is an unsigned 16-bit integer and is assumed to fit into the C unsigned int type. If the C type is smaller, the value will be coerced by the C compiler (double to unsigned int).
=example printf("ToUint16(): %u\n", duk_to_uint16(ctx, -3)); =tags stack =fixme Apply the duk_get_int() coercion to the result just in case? It would clamp output values to INT_MIN and INT_MAX. This is not very relevant because if int is smaller than 16 bits, everything will break anyway.