[英]Removing element from an array
function removeItem(){
for(i=0;i<rowData.length;i++){
if(rowData[i].title = 'First Name'){
rowData.splice(i,1);
break;
}
}
This does not delete the object whose has a title property 'First Name' instead deletes the last added object to the array.这不会删除具有标题属性“名字”的 object,而是删除最后添加到数组中的 object。
You have to use ==
operator instead of =
in the if condition.您必须在if条件中使用==
运算符而不是=
。 =
is for assignment and not for comparing. =
用于分配而不是用于比较。
Edit 1: For more info follow this thread.编辑 1:有关更多信息,请关注此线程。
On line three you have a typo.在第三行你有一个错字。 Instead of =
, it should say ==
而不是=
,它应该说==
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.