var whereJsonObj = []
//声明一个对象
var term = new Object()
term = new Object()
term.name = "search"
term.value = "123"
//给数组添加一个对象
whereJsonObj.push(term)
//删除前
console.log(whereJsonObj)
//删除这个对象
whereJsonObj = remove(whereJsonObj,"name","search");
//删除后
console.log(whereJsonObj )
//删除数组的函数
function remove(arrPerson,objPropery,objValue){
return $.grep(arrPerson, function(cur,i){
return cur[objPropery]!=objValue
})
}
var removeFromArray = function (arr, val) {var index = $.inArray(val, arr)
if (index >= 0)
arr.splice(index, 1)
return arr
}
console.log(removeFromArray([1, 2, 3, 4, 5], 4))
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)