乐趣区

关于javascript: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;
退出移动版