Splice 不适用于带有对象的数组,我收到以下错误。我只是根据情况重新排序东西。
this.generatePartipant = function(userData,creatorID) {
//arrange order based on order: owner, presenter and others
var creatorObject;
var ownerObject;
for(var i=0;i < userData.length; i++){
if(userData[i].senderId = creatorID)
{
creatorObject = jQuery.extend({},userData[i],{creator:true});
userData.splice(i,1);
}
if(userData[i].senderId = whiteboardDesigner.user){
ownerObject = jQuery.extend({},userData[i],{owner:true});
userData.splice(i,1);
}
}
if(creatorObject != null){
userData.push(creatorObject);
}
if (ownerObject != null){
userData.push(ownerObject);
}
}
> 错误:
userData.splice(i,1);
Uncaught TypeError: Object [{"senderId":"9e61ec7e-8d7c-469d-88e5-38213dcb34f4","userName":"lkwerj","thumbnailId":null,"active":true,"camStarted":false,"micStarted":false,"imageUrl":null}] has no method 'splice'