Is there a method to remove an item from a JavaScript array?
(有没有一种方法可以从JavaScript数组中删除项目?)
Given an array:
(给定一个数组:)
var ary = ['three', 'seven', 'eleven'];
I would like to do something like:
(我想做类似的事情:)
removeItem('seven', ary);
I've looked into splice()
but that only removes by the position number, whereas I need something to remove an item by its value.
(我已经研究过splice()
但是它只能通过位置编号删除,而我需要一些东西才能通过其值删除项目。)
ask by MacMac translate from so 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…