From 96da3a4db14056b2feb4419c78c51e7d4bcc1028 Mon Sep 17 00:00:00 2001 From: Minseok Choe Date: Mon, 5 Feb 2024 14:23:16 +0900 Subject: [PATCH] Add missed check in array-reduce.js --- packages/core-js/internals/array-reduce.js | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/core-js/internals/array-reduce.js b/packages/core-js/internals/array-reduce.js index 6bb4ab1a4f06..d17a6008dabc 100644 --- a/packages/core-js/internals/array-reduce.js +++ b/packages/core-js/internals/array-reduce.js @@ -13,6 +13,7 @@ var createMethod = function (IS_RIGHT) { var self = IndexedObject(O); var length = lengthOfArrayLike(O); aCallable(callbackfn); + if (length === 0 && argumentsLength < 2) throw new $TypeError('Reduce of empty array with no initial value'); var index = IS_RIGHT ? length - 1 : 0; var i = IS_RIGHT ? -1 : 1; if (argumentsLength < 2) while (true) {