JavaScript Array လျှော့ရန်Right()
ဥပမာများ
အဆုံးမှစတင်၍ array ရှိ နံပါတ်များကို နုတ်ပါ။
const numbers = [175, 50, 25];
document.getElementById("demo").innerHTML
= numbers.reduceRight(myFunc);
function myFunc(total, num) {
return total - num;
}
နံပါတ်များကို နုတ်ပါ၊ ညာမှဘယ်သို့၊ ပေါင်းလဒ်ကို ပြပါ-
const numbers = [2, 45, 30, 100];
document.getElementById("demo").innerHTML = numbers.reduceRight(getSum);
function getSum(total, num) {
return total - num;
}
အဓိပ္ပါယ်နှင့် အသုံးပြုမှု
နည်းလမ်း သည် reduceRight()
array element တစ်ခုစီအတွက် reducer function ကို လုပ်ဆောင်သည်။
နည်းလမ်း သည် reduceRight()
ညာမှဘယ်သို့အလုပ်လုပ်သည်။
reduceRight()
နည်းလမ်းသည် တန်ဖိုးတစ်ခုတည်းကို ပြန်ပေးသည်- လုပ်ဆောင်ချက်၏ စုစည်းမှုရလဒ် ။
နည်းလမ်း သည် reduceRight()
ဗလာဒြပ်စင်များအတွက် လုပ်ဆောင်ချက်ကို လုပ်ဆောင်ခြင်းမရှိပါ။
ကိုလည်းကြည့်ပါ-
အထားအသို
array.reduceRight(function(total, currentValue, currentIndex, arr), initialValue)
ကန့်သတ်ချက်များ
Parameter | Description | ||||||||
function() | Required. A function to be run for each element in the array. |
||||||||
Reducer function parameters:
| |||||||||
initialValue | Optional. A value to be passed to the function as the initial value |
တန်ဖိုးကို ပြန်ပေးသည်။
ပြန်ခေါ်သည့်လုပ်ဆောင်ချက်၏ နောက်ဆုံးခေါ်ဆိုမှုမှ စုဆောင်းထားသောရလဒ်။ |
Browser ပံ့ပိုးမှု
reduceRight()
ECMAScript5 (ES5) အင်္ဂါရပ်တစ်ခုဖြစ်သည်။
ES5 (JavaScript 2009) ကို ဘရောက်ဆာအားလုံးတွင် အပြည့်အဝထောက်ခံသည်-
Chrome | IE | Edge | Firefox | Safari | Opera |
Yes | 9-11 | Yes | Yes | Yes | Yes |