A javascript library for working with objects
Iterates over own properties of an object and returns a reduced value.
Returns: unknown
- The accumulated result.
Param | Type | Description |
---|---|---|
object | object |
The object to iterate over. |
callback | function |
Provides three args: result, value, and key. If the result is only mutated then you may not need to return it. |
initialValue | unknown |
The initial value passed into the callback as result. |
Example
import { forOwnReduce } from 'object-agent';
const thing = {
a: 'b',
c: 'd'
};
const output = forOwnReduce(thing, (result, value, key) => {
result.push([value, key]);
return result;
}, []);
console.log(output);
// => [['b', 'a'], ['d', 'c']]