How to get the object itself of the property name (does not include inherited properties)

There are two methods, Object.getOwnPropertyNames () and Object.keys ()

 

The first: Object.getOwnPropertyNames (obj) itself only acquired the properties defined parameter object, regardless of whether the property can be traversed.

Object.getOwnPropertyNames(Array);
// ["length", "name", "prototype", "isArray", "from", "of"]

 

The second: Object.keys () itself only acquired the properties defined parameter object, but will only get to traverse the properties.

Object.keys(Array);
// []

 

Guess you like

Origin www.cnblogs.com/aisowe/p/11686521.html