小编use*_*714的帖子

减少对象思想object.entries

我有这种对象

我想使用具有“ exist === true”键的新对象

const someObj  = {
      super: {
        exist: true
      },
      photo: {
        exist: true
      },
      request: {
        exist: false
      }
}
const newObj = Object.entries(someObj).reduce((newObj, [key, val]) => {
  if (this.key.exist) { // how to check "exist" is true ?
    return { ...newObj, [key]: val }
  }
}, {}))

console.log(newObj);
Run Code Online (Sandbox Code Playgroud)

javascript ecmascript-6

1
推荐指数
1
解决办法
1906
查看次数

标签 统计

ecmascript-6 ×1

javascript ×1