The for...in statement iterates over all enumerable properties of an object that are keyed by strings (ignoring ones keyed by Symbols), including inherited enumerable properties.
If you only want to consider properties attached to the object itself, and not its prototypes, use getOwnPropertyNames() or perform a hasOwnProperty()check (propertyIsEnumerable()can also be used). Alternatively, if you know there won’t be any outside code interference, you can extend built-in prototypes with a check method.
If you have an object (child) that inherits some properties from another object (parent), a for..in will loop through both the properties on the child and those inherited from the parent.