diff --git a/lib/internal/util/inspect.js b/lib/internal/util/inspect.js index b20ce167f9da44..c40083a1ad497b 100644 --- a/lib/internal/util/inspect.js +++ b/lib/internal/util/inspect.js @@ -43,6 +43,7 @@ const { ObjectPrototypePropertyIsEnumerable, ObjectSeal, ObjectSetPrototypeOf, + ReflectOwnKeys, RegExp, RegExpPrototypeTest, RegExpPrototypeToString, @@ -615,11 +616,7 @@ function addPrototypeProperties(ctx, main, obj, recurseTimes, output) { ArrayPrototypeForEach(keys, (key) => keySet.add(key)); } // Get all own property names and symbols. - keys = ObjectGetOwnPropertyNames(obj); - const symbols = ObjectGetOwnPropertySymbols(obj); - if (symbols.length !== 0) { - ArrayPrototypePush(keys, ...symbols); - } + keys = ReflectOwnKeys(obj); for (const key of keys) { // Ignore the `constructor` property and keys that exist on layers above. if (key === 'constructor' || @@ -667,7 +664,7 @@ function getKeys(value, showHidden) { if (showHidden) { keys = ObjectGetOwnPropertyNames(value); if (symbols.length !== 0) - keys.push(...symbols); + ArrayPrototypePush(keys, ...symbols); } else { // This might throw if `value` is a Module Namespace Object from an // unevaluated module, but we don't want to perform the actual type