name: duk_push_array proto: | duk_idx_t duk_push_array(duk_context *ctx); stack: | [ ... ] -> [ ... arr! ] summary: |
Push an empty array to the stack. Returns non-negative index (relative to stack bottom) of the pushed array.
example: | duk_idx_t arr_idx; arr_idx = duk_push_array(ctx); duk_push_string(ctx, "foo"); duk_put_prop_index(ctx, arr_idx, 0); duk_push_string(ctx, "bar"); duk_put_prop_index(ctx, arr_idx, 1); /* array is now: [ "foo", "bar" ], and array.length is 2 (automatically * updated for Ecmascript arrays). */ duk_pop(ctx); /* pop array */ tags: - stack - object introduced: 1.0.0