var foo = {a1:'1',a2:'2',a3:'3'};//获得对象所有属性的数组Object.getOwnPropertyNames(foo);> [ 'a1', 'a2', 'a3' ]//获取对象属性的个数Object.getOwnPropertyNames(foo).length;> 3
getOwnPropertyNames的浏览器支持
Feature | Chrome | Firefox | Internet Explorer | Opera | Safari |
Basic support | 5 | 4.0 | 9 | 12 | 5 |