SHARE
TWEET

Untitled

a guest Sep 20th, 2019 80 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. const flatten = obj =>
  2.   Object.keys(obj).reduce((acc, current) => {
  3.     const key = `${current}`;
  4.     const currentValue = obj[current];
  5.  
  6.     if (typeof currentValue === 'object') {
  7.       Object.assign(acc, flatten(currentValue));
  8.     } else {
  9.       acc[key] = currentValue;
  10.     }
  11.  
  12.     return acc;
  13.   }, {});
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top