从数组中删除不起作用

Deleting from an array doesn't work

本文关键字:不起作用 删除 数组      更新时间:2023-09-26

所以,如果数组的元素值不等于我指定的值,我正在尝试从数组中删除:

代码:http://pastebin.com/hUc3mVLv

$scope.enablePVR = function()
{
        for (i = 0; i < $scope.new_epg.length; i++) {
                start_time = convert_time($scope.new_epg[i].start);
                $scope.new_epg[i].title = $scope.new_epg[i].title.replace(/<(?:.|'n)*?>/gm, '');
                $scope.new_epg[i].description = "";
                $scope.new_epg[i].time = start_time;
        }
        archiveEPG = [];
        for(var i=0; i<archiveEPG.length; i++) {
                var e = document.getElementById("dateSelect");
                if($scope.new_epg[i].start.split(" ")[0] == e[e.selectedIndex].value) {
                        archiveEPG[archiveEPG.length+1] = $scope.new_epg[i];
                }
        }
        document.getElementById("dateSelect").remove(0);
        $scope.get_epg(null, true, archiveEPG);
}
.remove(0)无效,

您可以添加此函数以使其有效:

Array.prototype.remove = function(index) {
    return this.splice(index, 1); // The second parameter is the number of elements to remove.
}