Answers for "flatten nested object js"

0

flatten nested object js

Object.assign(
  {}, 
  ...function _flatten(o) { 
    return [].concat(...Object.keys(o)
      .map(k => 
        typeof o[k] === 'object' ?
          _flatten(o[k]) : 
          ({[k]: o[k]})
      )
    );
  }(yourObject)
)
Posted by: Guest on June-25-2020

Code answers related to "Javascript"

Browse Popular Code Answers by Language