1. 程式人生 > >js刪除陣列中某個特定的物件

js刪除陣列中某個特定的物件

var result.list = [{"key":"預約 ","value":"預約  "},{"key":"現場結束 ","value":"現場結束"},{"key":" 轉運維","value":"轉運維 "},{"key":" ","value":" "}]

//如果要刪除物件包含key="現場結束"的物件則

result.list.push({"key":"預約","value":"預約"});

var li = result.list;
var index;
if('${fwob.ordersource}'== '本地自建'){
for(var i=0;i<li.length;i++){
    if((li[i].key).indexOf("現場結束")>-1){
index = i;
li.splice(index,1);
}
}

}