to remove first and last element in array

后端 未结 12 796
鱼传尺愫
鱼传尺愫 2020-12-04 16:14

How to remove first and last element in an array?

For example:

var fruits = [\"Banana\", \"Orange\", \"Apple\", \"Mango\"];

Expecte

12条回答
  •  甜味超标
    2020-12-04 16:56

    This can be done with lodash _.tail and _.dropRight:

    var fruits = ["Banana", "Orange", "Apple", "Mango"];
    console.log(_.dropRight(_.tail(fruits)));

提交回复
热议问题