diff --git a/lib/internal/assert/assertion_error.js b/lib/internal/assert/assertion_error.js index f12243790b0506..5d8c45040af0fe 100644 --- a/lib/internal/assert/assertion_error.js +++ b/lib/internal/assert/assertion_error.js @@ -6,9 +6,9 @@ const { Error, ErrorCaptureStackTrace, MathMax, + ObjectAssign, ObjectDefineProperty, ObjectGetPrototypeOf, - ObjectKeys, String, StringPrototypeEndsWith, StringPrototypeRepeat, @@ -46,11 +46,7 @@ const kReadableOperator = { const kMaxShortLength = 12; function copyError(source) { - const keys = ObjectKeys(source); - const target = { __proto__: ObjectGetPrototypeOf(source) }; - for (const key of keys) { - target[key] = source[key]; - } + const target = ObjectAssign({ __proto__: ObjectGetPrototypeOf(source) }, source); ObjectDefineProperty(target, 'message', { __proto__: null, value: source.message }); return target; }