You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If an array is empty, calling reduce/reduceRight method will cause runtime error. We need a rule to force passing initial value to reduce/reduceRight method
constnums: number[]=[];constsum=nums.reduce((result,num)=>result+num);// This will cause runtime error
Description
If an array is empty, calling
reduce
/reduceRight
method will cause runtime error. We need a rule to force passing initial value toreduce
/reduceRight
methodFail
Pass
Proposed rule name
require-reduce-initial-value
Additional Info
No response
The text was updated successfully, but these errors were encountered: