Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commite7f6af0

Browse files
committed
use a constant as a error message
1 parentb36ca26 commite7f6af0

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

‎packages/core-js/internals/array-reduce.js‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,16 @@ var lengthOfArrayLike = require('../internals/length-of-array-like');
66

77
var$TypeError=TypeError;
88

9+
varREDUCE_EMPTY='Reduce of empty array with no initial value';
10+
911
// `Array.prototype.{ reduce, reduceRight }` methods implementation
1012
varcreateMethod=function(IS_RIGHT){
1113
returnfunction(that,callbackfn,argumentsLength,memo){
1214
varO=toObject(that);
1315
varself=IndexedObject(O);
1416
varlength=lengthOfArrayLike(O);
1517
aCallable(callbackfn);
16-
if(length===0&&argumentsLength<2)thrownew$TypeError('Reduce of empty array with no initial value');
18+
if(length===0&&argumentsLength<2)thrownew$TypeError(REDUCE_EMPTY);
1719
varindex=IS_RIGHT ?length-1 :0;
1820
vari=IS_RIGHT ?-1 :1;
1921
if(argumentsLength<2)while(true){
@@ -24,7 +26,7 @@ var createMethod = function (IS_RIGHT) {
2426
}
2527
index+=i;
2628
if(IS_RIGHT ?index<0 :length<=index){
27-
thrownew$TypeError('Reduce of empty array with no initial value');
29+
thrownew$TypeError(REDUCE_EMPTY);
2830
}
2931
}
3032
for(;IS_RIGHT ?index>=0 :length>index;index+=i)if(indexinself){

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp