【新手】如何删除数组中的某一项

properties: {
taskArray:[Task]
}

this._taskArray[0] = new Task();
this._taskArray[1] = new Task();
this._taskArray.removeAt(0);

这样会报错,应该怎么写?请教

delete吗?

js: this._taskArray.splice(0, 1);
mdn教程
creator封装函数:

/**
 * Removes the array item at the specified index.
 * @method removeAt
 * @param {any[]} array
 * @param {Number} index
 */
function removeAt (array, index) {
    array.splice(index, 1);
}

/**
 * Removes the array item at the specified index.
 * It's faster but the order of the array will be changed.
 * @method fastRemoveAt
 * @param {any[]} array
 * @param {Number} index
 */
function fastRemoveAt (array, index) {
    var length = array.length;
    if (index < 0 || index >= length) {
        return;
    }
    array[index] = array[length - 1];
    array.length = length - 1;
}

话说这个搜索一下,会没有结果吗?

removeChild(item)

直接 delete this._taskArray[0]

谢谢啦

.splice(0,1)