=proto void duk_get_var(duk_context *ctx); =stack [ ... varname! ] -> [ ... val! ] =summary

Look up identifier varname. Possible outcomes:

The identifier lookup is equivalent to the Ecmascript expression:

varname

For semantics, see Identifier Resolution, GetIdentifierReference (lex, name, strict), Identifier Reference, GetValue (V). Ecmascript semantics require that a ReferenceError be thrown if the identifier cannot be resolved (this is the case even in non-strict mode).

Because Duktape/C functions cannot currently be nested functions, their outer lexical environment is always the global environment.
=example duk_push_string(ctx, "Math"); duk_get_var(ctx); /* [ ... "Math" ] -> [ ... Math ] */ duk_get_prop_string(ctx, -1, "PI"); /* -> [ ... Math PI ] */ printf("Math.PI=%lf\n", duk_get_number(ctx, -1)); duk_pop_2(ctx); =tags variable omit =fixme Although Ecmascript semantics always require a ReferenceError for unresolvable identifiers, it might fit the API better to return zero if identifier is not found and non-zero if found. This would match the property access API. Incomplete.