Stories

Detail Return Return

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
0 users favorite the story!

Post Comments

Some HTML is okay.