Is it possible to get the non-enumerable inherited property names of an object?

后端 未结 9 1889
温柔的废话
温柔的废话 2020-11-22 12:46

In JavaScript we have a few ways of getting the properties of an object, depending on what we want to get.

1) Object.keys(), which returns all own, enu

9条回答
  •  再見小時候
    2020-11-22 13:48

    if you are trying to log non enumerable properties of a parent object ex. by default the methods defined inside a class in es6 are set on prototype but are set as non-enumerable.

    Object.getOwnPropertyNames(Object.getPrototypeOf(obj));
    

提交回复
热议问题