Loops
/ API Reference
Loops
/ API Reference

objectEach

Iterates over each value in the object.
Similar to Array.prototype.forEach, but for objects.

The Gist

import { objectEach } from '@weser/loops'

objectEach({ a: 1, b: 2, c: 3 }, (value) => console.log(value, key))
// 1 a
// 2 b
// 3 c

Parameters

ParameterTypeDescription
objRecord<PropertyKey, any>The object to iterate over.
iterator(value: any, key: PropertyKey, obj: Record<PropertyKey, any>) => voidThe iterator method with the signature.
On this page