JavaScript Array အချပ်()
ဥပမာများ
အစိတ်အပိုင်းများကို ရွေးပါ-
const fruits = ["Banana", "Orange", "Lemon", "Apple", "Mango"];
const citrus = fruits.slice(1, 3);
အနှုတ်တန်ဖိုးများကို အသုံးပြု၍ အစိတ်အပိုင်းများကို ရွေးပါ
const fruits = ["Banana", "Orange", "Lemon", "Apple", "Mango"];
const myBest = fruits.slice(-3, -1);
အဓိပ္ပါယ်နှင့် အသုံးပြုမှု
slice()
နည်းလမ်းသည် array အသစ်တစ်ခုအနေဖြင့် ရွေးချယ်ထားသော အစိတ်အပိုင်းများကို ပြန်ပေးသည် ။
slice()
နည်းလမ်းသည် ပေးထားသော အ စ မှ၊ ပေးထားသော (မပါဝင်) အ ဆုံးအထိ ရွေးချယ်သည် ။
နည်းလမ်းသည် မူရင်း slice()
array ကို မပြောင်းလဲပါ။
အထားအသို
array.slice(start, end)
ကန့်သတ်ချက်များ
Parameter | Description |
start | Optional. Start position. Default is 0. Negative numbers select from the end of the array. |
end | Optional. End position. Default is last element. Negative numbers select from the end of the array. |
တန်ဖိုးကို ပြန်ပေးသည်။
ရွေးချယ်ထားသော ဒြပ်စင်များပါရှိသော အခင်းအသစ်တစ်ခု။ |
Browser ပံ့ပိုးမှု
slice()
ECMAScript1 (ES1) အင်္ဂါရပ်တစ်ခုဖြစ်သည်။
ES1 (JavaScript 1997) ကို ဘရောက်ဆာအားလုံးတွင် အပြည့်အဝ ပံ့ပိုးထားသည်။
Chrome | IE | Edge | Firefox | Safari | Opera |
Yes | Yes | Yes | Yes | Yes | Yes |