JavaScript Array copyWithin()
ဥပမာများ
ပထမ array element နှစ်ခုကို နောက်ဆုံး array element နှစ်ခုသို့ ကူးယူပါ-
const fruits = ["Banana", "Orange", "Apple", "Mango"];
fruits.copyWithin(2, 0);
ပထမ array အစိတ်အပိုင်းနှစ်ခုကို တတိယနှင့် စတုတ္ထနေရာသို့ ကူးယူပါ-
const fruits = ["Banana", "Orange", "Apple", "Mango", "Kiwi"];
fruits.copyWithin(2, 0, 2);
အဓိပ္ပါယ်နှင့် အသုံးပြုမှု
နည်းလမ်း သည် copyWithin()
array အစိတ်အပိုင်းများကို array အတွင်းရှိ အခြားနေရာသို့ ကူးယူသည်။
နည်းလမ်း သည် copyWithin()
ရှိပြီးသားတန်ဖိုးများကို ထပ်ရေးသည်။
နည်းလမ်း သည် copyWithin()
array တွင် အရာများကို မထည့်ပါ။
အထားအသို
array.copyWithin(target, start, end)
ကန့်သတ်ချက်များ
Parameter | Description |
target | Required. The index (position) to copy the elements to. |
start | Optional. The start index (position). Default is 0. |
end | Optional. The end index (position). Default is the array length. |
တန်ဖိုးကို ပြန်ပေးသည်။
ရိုက်ပါ။ | ဖော်ပြချက် |
ဇွတ်တစ်ခု | ပြောင်းလဲထားသော ခင်းကျင်းမှု။ |
Browser ပံ့ပိုးမှု
copyWithin()
ECMAScript6 (ES6) အင်္ဂါရပ်တစ်ခုဖြစ်သည်။
ES6 (JavaScript 2015) ကို ခေတ်မီဘရောက်ဆာများအားလုံးတွင် ပံ့ပိုးထားပါသည်။
Chrome | Edge | Firefox | Safari | Opera |
Yes | Yes | Yes | Yes | Yes |
copyWithin()
Internet Explorer 11 (သို့မဟုတ်အစောပိုင်း) တွင် မပံ့ပိုးပါ။