javaScript通过匹配元素移除数组元素

mac2022-06-30  33

Array.prototype.indexOf = function(val) { for (var i = 0; i < this.length; i++) { if (this[i] == val) return i; } return -1; }; Array.prototype.remove = function(val) { var index = this.indexOf(val); if (index > -1) { this.splice(index, 1); } };

  

转载于:https://www.cnblogs.com/renewload/p/11435500.html

最新回复(0)