JS 移除数组中指定索引项

JS移除数组中的指定的索引的项:

        //
        //移除指定索引的对象
        Array.prototype.remove = function (dx) {
            if (isNaN(dx) || dx > this.length) { return false; }
            for (var i = 0, n = 0; i < this.length; i++) {
                if (this[i] != this[dx]) {
                    this[n++] = this[i]
                }
            }
            this.length -= 1
        }
调用:

       var PhotoList = [];       //存在这样一个数组
       PhotoList.remove(0);   //调用



你可能感兴趣的:([24],JavaScript)