diff --git a/lib/internal/util/comparisons.js b/lib/internal/util/comparisons.js index d86e59adae9880..d26d887636c565 100644 --- a/lib/internal/util/comparisons.js +++ b/lib/internal/util/comparisons.js @@ -21,6 +21,7 @@ const { StringPrototypeValueOf, SymbolPrototypeValueOf, TypedArrayPrototypeGetSymbolToStringTag, + TypedArrayPrototypeGetByteLength, Uint8Array, } = primordials; @@ -71,7 +72,8 @@ function areSimilarFloatArrays(a, b) { if (a.byteLength !== b.byteLength) { return false; } - for (let offset = 0; offset < a.byteLength; offset++) { + const len = TypedArrayPrototypeGetByteLength(a); + for (let offset = 0; offset < len; offset++) { if (a[offset] !== b[offset]) { return false; }