動態

詳情 返回 返回

JS如何刪除對象中的某一屬性 - 動態 詳情

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

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

結果:

user avatar grewer 頭像 yinzhixiaxue 頭像 zhaobuhui 頭像 u_17443142 頭像 xiaolei_599661330c0cb 頭像 assassin 頭像 yanyue404 頭像 heath_learning 頭像 huanjinliu 頭像 cynthia_59675eba1a2ee 頭像 hsr2022 頭像 robin_ren 頭像
點贊 56 用戶, 點贊了這篇動態!
點贊

Add a new 評論

Some HTML is okay.