diff --git a/src/array/groupBy.ts b/src/array/groupBy.ts index 797e4a1ae..09979741a 100644 --- a/src/array/groupBy.ts +++ b/src/array/groupBy.ts @@ -37,7 +37,7 @@ export function groupBy(arr: readonly T[], getKeyFromI const item = arr[i]; const key = getKeyFromItem(item); - if (result[key] == null) { + if (!Object.hasOwn(result, key) || result[key] == null) { result[key] = []; }