name: duk_put_global_string proto: | duk_bool_t duk_put_global_string(duk_context *ctx, const char *key); stack: | [ ... val! ] -> [ ... ] summary: |
Put property named key
to the global object.
Return value behaves similarly to
duk_put_prop()
.
This is a convenience function which does the equivalent of:
duk_bool_t ret; duk_push_global_object(ctx); duk_insert(ctx, -2); ret = duk_put_prop_string(ctx, -2, key); duk_pop(ctx); /* 'ret' would be the return value from duk_put_global_string() */example: | duk_push_string(ctx, "1.2.3"); (void) duk_put_global_string(ctx, "my_app_version"); tags: - property - string seealso: - duk_put_global_lstring - duk_put_global_literal - duk_put_global_heapptr introduced: 1.0.0