I have an object which I want to filter. This is what I use:
query = {
"teststring-123": "true",
"teststring-12344566": "false",
test: "true"
}
I want to filter query so that after filtering I just have:
query = {
"teststring-123": "true",
"teststring-12344566": "false"
}
$(query).each(function(index, value) {
$.each(value, function(i, v) {
if(i.indexOf('teststring-')==-1) {
// remove part of query object where index is this one
console.log(index)
}
});
});
How can I handle this?
Use the
deleteoperator:http://jsfiddle.net/NvZyA/ (in this demo,
Object.keys()is used to show all keys).