動態

詳情 返回 返回

js獲取對象的屬性個數 - 動態 詳情

let math = {
    subject: '數學',
    children: [
        { id: 1, title: '數一' }, 
        { id: 2, title: '數二' }, 
        { id: 3, title: '數三' }, 
        { id: 0, title: '待定' }
    ]
}
// 取對象的屬性個數
Object.getOwnPropertyNames(math).length;
Object.keys(math).length;
user avatar toopoo 頭像 zourongle 頭像 linx 頭像 anchen_5c17815319fb5 頭像 hard_heart_603dd717240e2 頭像 jiavan 頭像 yqyx36 頭像 yangxiansheng_5a1b9b93a3a44 頭像 congjunhua 頭像 DolphinScheduler 頭像 morimanong 頭像 wubomu 頭像
點贊 51 用戶, 點贊了這篇動態!
點贊

Add a new 評論

Some HTML is okay.