📌  相关文章
📜  nodejs 添加新的属性数组对象 - Javascript 代码示例

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

代码示例1
const data = [{ name: 'dendi', age: 23 }, { name: 'dhani' }]
const result = data.filter((v, i) => {
    if (!Object.keys(v).includes('age')) {
        Object.defineProperty(v, 'age', {
            value: 25,
            writeable: true,
            enumerable: true
        })
    }
    return v
})