name: duk_trim proto: | void duk_trim(duk_context *ctx, duk_idx_t idx); stack: | [ ... str! ... ] -> [ ... trimmed_str! ... ] summary: |

Trim string at idx. If the value at idx is not a string or the index is invalid, throws an error.

Trimming removes white space characters from the beginning and end the end of the string. The result is an empty string if the string consists entirely of white space characters. The set of characters considered to be white space is defined by the StrWhiteSpace production, which contains both WhiteSpace and LineTerminator characters. The trimming behavior matches those of String.prototype.trim(), parseInt(), and parseFloat().

example: | duk_trim(ctx, -3); tags: - stack - string introduced: 1.0.0