to remove first and last element in array

后端 未结 12 795
鱼传尺愫
鱼传尺愫 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条回答
  •  猫巷女王i
    2020-12-04 16:33

    You used Fruits.shift() method to first element remove . Fruits.pop() method used for last element remove one by one if you used button click. Fruits.slice( start position, delete element)You also used slice method for remove element in middle start.

提交回复
热议问题