name: duk_swap_top proto: | void duk_swap_top(duk_context *ctx, duk_idx_t idx); stack: | [ ... val1! ... val2! ] -> [ ... val2! ... val1! ] summary: |

Swap stack top with value at idx. If idx refers to the stack top, the call is a no-op. If the value stack is empty or idx is invalid, throws an error.

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