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 12 




 

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-11-06
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-09-17
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案