How to easily truncate an array with JavaScript?

后端 未结 6 1245
被撕碎了的回忆
被撕碎了的回忆 2020-12-02 16:09

Linq has a convenient operator method called Take() to return a given number of elements in anything that implements IEnumerable. Is there anything

6条回答
  •  心在旅途
    2020-12-02 16:54

    If you want to both get the elements as well as remove them from the array, use splice.

    If you want to keep the elements in the array, use slice

提交回复
热议问题