A javascript library for working with objects
Iterates over own properties of an object and returns a reduced value
Returns: *
- The accumulated result
Param | Type | Description |
---|---|---|
object | Object |
|
callback | function |
Provides three args: result, value, and key. If the result is only mutated then you may not need to return it. |
initialValue | * |
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']]