这是我向数组添加元素的方式assets.push(house_location + " " + "Cost" + " " + cost + " " + "Downpay"+ " " + downpay)现在我正在寻找一种方法来从我的数组中删除相同的特定元素。有人知道这个代码吗?所以基本上,与array.push相反
3 回答
冉冉说
TA贡献1877条经验 获得超1个赞
如果要删除最后推送的项目,请使用assets.pop()。如果你想像你说的那样删除那个确切的项目,你可以这样做:
assets.filter(d => d !== house_location + " " + "Cost" + " " + cost + " " + "Downpay"+ " " + downpay)
忽然笑
TA贡献1806条经验 获得超5个赞
我猜你正在寻找这些方法。
Array.shift() // Removes the first item from an array, and then returns the item removed.
Array.pop() // Removes the last item from an array, and then returns the item removed.
Array.splice() // I really can't be bothered to explain this one, so look at the link below.
添加回答
举报
0/150
提交
取消