diff --git a/lib/internal/util.js b/lib/internal/util.js index f26ea970e8dce0..aa71b5b22db707 100644 --- a/lib/internal/util.js +++ b/lib/internal/util.js @@ -3,6 +3,7 @@ const { ArrayFrom, ArrayIsArray, + ArrayPrototypeJoin, Error, Map, ObjectCreate, @@ -323,10 +324,14 @@ function promisify(original) { promisify.custom = kCustomPromisifiedSymbol; -// The build-in Array#join is slower in v8 6.0 +// The built-in Array#join is slower in v8 6.0 function join(output, separator) { let str = ''; if (output.length !== 0) { + // The built-in Array#join is faster in v8 7.8 + if (ArrayIsArray(output)) { + return ArrayPrototypeJoin(output, separator); + } const lastIndex = output.length - 1; for (let i = 0; i < lastIndex; i++) { // It is faster not to use a template string here