📜  对象展平 js - Javascript 代码示例

📅  最后修改于: 2022-03-11 15:02:13.790000             🧑  作者: Mango

代码示例1
Object.assign(
  {}, 
  ...function _flatten(o) { 
    return [].concat(...Object.keys(o)
      .map(k => 
        typeof o[k] === 'object' ?
          _flatten(o[k]) : 
          ({[k]: o[k]})
      )
    );
  }(yourObject)
)