mirror of https://github.com/svaarala/duktape.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
29 lines
810 B
29 lines
810 B
=proto
|
|
void duk_insert(duk_context *ctx, int to_index);
|
|
|
|
=stack
|
|
[ ... old(to_index)! ... val! ] -> [ ... val(to_index)! old! ... ]
|
|
|
|
=summary
|
|
<p>Insert a value at <code>to_index</code> with a value popped from the
|
|
stack top. The previous value at <code>to_index</code> and any values
|
|
above it are moved up the stack by a step. If <code>to_index</code> is
|
|
an invalid index, throws an error.</p>
|
|
|
|
<div class="note">
|
|
Negative indices are evaluated prior to popping the value at the stack
|
|
top. This is also illustrated by the example.
|
|
</div>
|
|
|
|
=example
|
|
duk_push_int(ctx, 123);
|
|
duk_push_int(ctx, 234);
|
|
duk_push_int(ctx, 345); /* -> [ 123 234 345 ] */
|
|
duk_push_string(ctx, "foo"); /* -> [ 123 234 345 "foo" ] */
|
|
duk_insert(ctx, -3); /* -> [ 123 "foo" 234 345 ] */
|
|
|
|
=tags
|
|
stack
|
|
|
|
=seealso
|
|
duk_replace
|
|
|