A javascript library for working with objects
Iterates over own properties of an object. Stops iterating as soon as the callback returns a truthy value.
Returns: boolean
- True if the callback function returns a truthy value for any key, otherwise false.
Param | Type | Description |
---|---|---|
object | object |
The object to iterate over. |
callback | function |
Provides two args: value and key. |
Example
import { forOwn } from 'object-agent';
const thing = {
a: 'b',
c: 'd'
};
forOwn(thing, (value, key) => {
console.log(value, key);
});
// => 'b', 'a'
// => 'd', 'c'