js刪除數組中的指定元素的方法為:
Array.prototype.remove = function(val) { var index = this.indexOf(val); if (index > -1) { this.splice(index, 1); } }
調用方式為
var element = "xx" arr.remove(element)
即可從數組中刪除指定元素。
js刪除數組中的指定元素的方法為:
Array.prototype.remove = function(val) { var index = this.indexOf(val); if (index > -1) { this.splice(index, 1); } }
調用方式為
var element = "xx" arr.remove(element)
即可從數組中刪除指定元素。
本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。