Object iteration
Less than 1 minute
Object iteration
Note
This proposal has been withdrawn and will be removed from the next major Core-JS version.
Modules
Types
interface Object {
iterateKeys(object: { [k: PropertyKey]: any }): Iterator<string>;
iterateValues<T>(object: { [k: PropertyKey]: T }): Iterator<T>;
iterateEntries<T>(object: { [k: PropertyKey]: T }): Iterator<[string, T]>;
}
Entry points
core-js/proposals/object-iteration
core-js(-pure)/full/object/iterate-keys
core-js(-pure)/full/object/iterate-values
core-js(-pure)/full/object/iterate-entries
Example
const obj = { foo: "bar", baz: "blah" };
for (const [key, value] of Object.iterateEntries(obj)) {
console.log(`${key} -> ${value}`);
}
for (const key of Object.iterateKeys(obj)) {
console.log(key);
}
for (const value of Object.iterateValues(obj)) {
console.log(value);
}