Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const flatten = obj =>
- Object.keys(obj).reduce((acc, current) => {
- const key = `${current}`;
- const currentValue = obj[current];
- if (typeof currentValue === 'object') {
- Object.assign(acc, flatten(currentValue));
- } else {
- acc[key] = currentValue;
- }
- return acc;
- }, {});
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement