How do you iterate over all methods in the JavaScript pseudo-class, regardless of whether they are marked as enumerated?

I am trying to iterate through all the methods of the JavaScript pseudoword and can easily determine if something is a method or not (obj.member instanceof Function), however I am trying to include methods that can be hidden from for ... in loop via defineProperty with enumerated flag set to false - how can I repeat all members of the pseudo-class, regardless of the enumerated value?

+6
source share
1 answer

You can always use Object.getOwnPropertyNames , which will include non-enumerable properties. However, this will not include prototype properties, so if you ask about “pseudo- Object.getPrototypeOf instances”, you might need to loop the prototype chain with Object.getPrototypeOf .

+7
source

All Articles