js中数组插入、删除元素操作的方法

guoqinggai22423 29 0 PDF 2020-12-13 06:12:00

实例如下: /* * 删除数组元素:Array.removeArr(index) */ Array.prototype.removeArr = function (index) { if (isNaN(index) || index>= this.length) { return false; } this.splice(index, 1); } /* * 插入数组元素:Array.insertArr(dx) */ Array.prototype.insertArr = function (index, item) { this.spl

用户评论
请输入评论内容
评分:
暂无评论