isDone
const obj = { a: 1, b: 2, c: 3 };
function feo(obj: object) {
const arr: any[] = [];
forEachObj(obj, (v, k, obj) => {
arr.push([v, k, obj]);
});
return arr;
}
isEqual(feo(obj),
Object.keys(obj).reduce((res, key) => {
res.push([obj[key], key, obj]);
return res;
}, [] as any[]),
); // true
feo(obj).length; // 3
// 不会遍历继承的属性
feo(Object.create(obj)).length; // 0
遍历对象属性
代替Object.keys(obj).forEach