对象迭代
小于 1 分钟
对象迭代
注意
该提案已被撤回,并将从下一个主要的 Core-JS 版本中删除。
模块
类型
class Object {
iterateKeys(object: any): Iterator<string>;
iterateValues(object: any): Iterator<any>;
iterateEntries(object: any): Iterator<[string, any]>;
}
入口点
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
示例
示例:
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);
}