slice array from N to last element

前端 未结 7 2021
你的背包
你的背包 2020-12-29 01:11

How to make this transformation?

[\"a\",\"b\",\"c\",\"d\",\"e\"] // => [\"c\", \"d\", \"e\"]

I was thinking that slice can

7条回答
  •  失恋的感觉
    2020-12-29 01:39

    Slice ends at the specified end argument but does not include it. If you want to include it you have to specify the last index as the length of the array (5 in this case) as opposed to the end index (-1) etc.

    ["a","b","c","d","e"].slice(2,5) 
    // = ['c','d','e']
    

提交回复
热议问题