Skip to content

this & Object Prototypes - Chapter 3 : 'in' operator  #1271

Open
@animeshk874

Description

@animeshk874

There's a paragraph related to the in operator that goes like this :

There's (currently) no built-in way to get a list of all properties which is equivalent to what the in operator test would consult (traversing all properties on the entire [[Prototype]] chain, as explained in Chapter 5). You could approximate such a utility by recursively traversing the [[Prototype]] chain of an object, and for each level, capturing the list from Object.keys(..) -- only enumerable properties.

Why do we need to capture only the enumerable properties. The in operator also checks for non-enumerable properties as well. So instead of using Object.keys(), shouldn't we use Object.getOwnPropertyNames() to build the utility?

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions