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

StackOverflow https://stackoverflow.com/questions/15094127

문제

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?

도움이 되었습니까?

해결책

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top