Javascript 切片不';t似乎在函数数组中工作

Javascript 切片不';t似乎在函数数组中工作,javascript,arrays,Javascript,Arrays,我有这个功能: function UIAlerts() {} 然后,我使用原型方法将一个变量关联到此函数中: UIAlerts.prototype.questions = [] 之后,我将一个函数推送到该数组: UIAlerts.prototype.questions.push(function(){ //do stuff }); 执行单击事件后,执行以下代码: if (UIAlerts.prototype.questions && UIAlerts.protot

我有这个功能:

function UIAlerts() {}
然后,我使用原型方法将一个变量关联到此函数中:

UIAlerts.prototype.questions = []
之后,我将一个函数推送到该数组:

UIAlerts.prototype.questions.push(function(){
     //do stuff
});
执行单击事件后,执行以下代码:

if (UIAlerts.prototype.questions && UIAlerts.prototype.questions.length > 0) {
        UIAlerts.prototype.questions.slice(0, 1);
        UIAlerts.prototype.questions[0] && UIAlerts.prototype.questions[0]();
}

if (UIAlerts.prototype.questions.length == 0)
    UIAlerts.prototype.questions = undefined;

问题是切片没有删除函数数组的第一个possion。有什么想法吗?

切片不会修改数组,它会返回该部分的副本


您正在查找
数组.prototype.splice
切片
不修改数组,它返回该节的副本

您正在寻找
阵列.prototype.splice