Why doesn’t deleting from a Javascript array change its length?

前端 未结 6 1889
不思量自难忘°
不思量自难忘° 2020-12-03 17:55

I have an array:

data.Dealer.car[0]
data.Dealer.car[1]
data.Dealer.car[2]

If I do this:

alert(data.Dealer.car.length);
dele         


        
6条回答
  •  借酒劲吻你
    2020-12-03 18:23

    Array.shift() would remove the first item from the array and make it shorter. Array.pop() will remove the last item.

提交回复
热议问题