name: duk_enum proto: | void duk_enum(duk_context *ctx, duk_idx_t obj_idx, duk_uint_t enum_flags); stack: | [ ... obj! ... ] -> [ ... obj! ... enum! ] summary: |
Create an enumerator for object at obj_idx
. Enumeration
details can be controlled with enum_flags
. If the target value
is not an object, throws an error.
Enumeration flags:
DUK_ENUM_INCLUDE_NONENUMERABLE | Enumerate also non-enumerable properties, by default only enumerable properties are enumerated |
DUK_ENUM_INCLUDE_HIDDEN | Enumerate also hidden Symbols, by default hidden Symbols are not
enumerated. Use together with DUK_ENUM_INCLUDE_SYMBOLS .
In Duktape 1.x this flag was called DUK_ENUM_INCLUDE_INTERNAL . |
DUK_ENUM_INCLUDE_SYMBOLS | Include Symbols in the enumeration result. Hidden Symbols are not
included unless DUK_ENUM_INCLUDE_HIDDEN is specified. |
DUK_ENUM_EXCLUDE_STRINGS | Exclude strings from the enumeration result. By default strings are included. |
DUK_ENUM_OWN_PROPERTIES_ONLY | Enumerate only an object's "own" properties, by default also inherited properties are enumerated |
DUK_ENUM_ARRAY_INDICES_ONLY | Enumerate only array indices, i.e. property names of the form "0", "1", "2", etc |
DUK_ENUM_SORT_ARRAY_INDICES | Apply the ES2015 [[OwnPropertyKeys]] enumeration order over the whole enumeration result rather than per inheritance level, this has the effect of sorting array indices (even when inherited) |
DUK_ENUM_NO_PROXY_BEHAVIOR | Enumerate a Proxy object itself without invoking Proxy behaviors. |
Without any flags the enumeration behaves like for-in
:
own and inherited enumerable properties are included, and enumeration
order follows the
Ecmascript ES2015 [[OwnPropertyKeys]]
enumeration order, applied for each inheritance level.
Once the enumerator has been created, use
duk_next()
to extract keys (or key/value
pairs) from the enumerator.
DUK_ENUM_SORT_ARRAY_INDICES
.