How do you iterate over all methods in a JavaScript pseudoclass, regardless of whether or not they are marked enumerable? - Stac

I'm trying to iterate over all methods in a JavaScript pseudoclass and can easily tell if somethin

I'm trying to iterate over all methods in a JavaScript pseudoclass and can easily tell if something is a method or not with (obj.member instanceof Function), however I'm trying to include methods that may be hidden from a for...in loop via defineProperty with an enumerable flag set to false - how do I iterate all members of a pseudoclass, regardless of the enumerable value?

I'm trying to iterate over all methods in a JavaScript pseudoclass and can easily tell if something is a method or not with (obj.member instanceof Function), however I'm trying to include methods that may be hidden from a for...in loop via defineProperty with an enumerable flag set to false - how do I iterate all members of a pseudoclass, regardless of the enumerable value?

Share Improve this question asked Feb 26, 2013 at 16:22 CoryGCoryG 2,5914 gold badges30 silver badges63 bronze badges 0
Add a ment  | 

1 Answer 1

Reset to default 13

You can always use Object.getOwnPropertyNames, which will include non-enumerable properties as well. However, this will not include properties from prototypes, so if you are asking about "pseudoclass instances" you might need to loop the prototype chain with Object.getPrototypeOf.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1743726093a4496639.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信