diff --git a/lib/buffer.js b/lib/buffer.js index 281b5d56a6cb9c..6185ccb8635b23 100644 --- a/lib/buffer.js +++ b/lib/buffer.js @@ -24,6 +24,7 @@ const { Array, ArrayIsArray, + ArrayPrototypeForEach, Error, MathFloor, MathMin, @@ -841,11 +842,12 @@ Buffer.prototype[customInspectSymbol] = function inspect(recurseTimes, ctx) { if (ctx) { let extras = false; const filter = ctx.showHidden ? ALL_PROPERTIES : ONLY_ENUMERABLE; - const obj = getOwnNonIndexProperties(this, filter).reduce((obj, key) => { - extras = true; - obj[key] = this[key]; - return obj; - }, ObjectCreate(null)); + const obj = ObjectCreate(null); + ArrayPrototypeForEach(getOwnNonIndexProperties(this, filter), + (key) => { + extras = true; + obj[key] = this[key]; + }); if (extras) { if (this.length !== 0) str += ', ';