动态

详情 返回 返回

JS如何刪除對象中的某一屬性

let math = {
    subject: '數學',
    children: [
        { id: 1, title: '數一' }, 
        { id: 2, title: '數二' }, 
        { id: 3, title: '數三' }, 
        { id: 0, title: '待定' }
    ]
}

// 添加新屬性
math.remark = "備註";
// 刪除對象中某一屬性
delete math.subject

結果:

user avatar
0 用户, 点赞了这篇动态!

发布 评论

Some HTML is okay.