JSFiddle - React, Tailwind, and code Playground

HTML

<div>Expected 3</div>
<div>Expected <span id="ret">x</span></div>

JavaScript

Array.prototype.reduceRight=function(a,b,c,d,e,f){c=this,d=c.length-1;while(!b)b=c[d--];for(e=c[d];d>=0;)e=c[d--],e!=f?b=a(b,e,d,c):0;return b}
    
Array.prototype.reduceRight =
    function(a,b,c,d,e,f){
        c=this,
        d=c.length-1;

        while(!b)b=c[d--];

        for(e=c[d]; d>-1; d--)
            e=c[d],
            e!=f ? b=a(b,e,d,c) : 0;

        return b
    }

//$("#ret").html([1,2].reduceRight(function (a,b){return a+b}));
//$("#ret").html([1,2,,,,,].reduceRight(function (a,b){return a+b}));
                
$("#ret").html([1,2].reduceRight(function(a,b,c,d){console.log(a,b,c,d);return a+b}));