List Object's built-in Properties

前端 未结 5 2038
小蘑菇
小蘑菇 2021-02-06 11:52

Is there a way for me to loop over a Javascript Object\'s built-in properties?

for...in gets me close to where I want to go, but \"A for...in loop does not iterate over

5条回答
  •  独厮守ぢ
    2021-02-06 12:36

    I realize this question is three years old, but now, with ES5, it is possible:

    >>> Object.getOwnPropertyNames(Object)

    ["prototype", "getPrototypeOf", "getOwnPropertyDescriptor", "keys", "defineProperty", "defineProperties", "create", "getOwnPropertyNames", "isExtensible", "preventExtensions", "freeze", "isFrozen", "seal", "isSealed", "length", "arity", "name", "arguments", "caller"]

提交回复
热议问题