我有这种对象
我想使用具有“ 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)