I have a dictionary object in jQuery that contains data like this:
var category = [];
var brand = [];
var parameter = [];
category = $("input:checkbox[name=category]:checked").map(function() {
return this.value;
}).get();
brand = $("input[type='radio']:checked").map(function() {
return this.value;
}).get();
parameter.push({
brand: brand,
category: category,
});
Then I tried to remove the key and value pair from parameter dictonary like this but nothing got removed:
var brand = "something"
delete parameter.brand
console.log(parameter)
the parameter dictionary looks like this
Array[2]
0: Object
brand: Array[1]
0: "spykar"
length: 1
__proto__: Array[0]
category: Array[1]
0: "Men Jeans"
length: 1
__proto__: Array[0]
__proto__: Object
1: Object
brand: Array[1]
0: "Madame"
length: 1
__proto__: Array[0]
category: Array[1]
__proto__: Object
length: 2
__proto__: Array[0]
edit
As per Zamuka told me i tried to filter the array like this
$table.on('click', '.remove', function() {
var brand = $(this).closest('td').prev('td').prev('td').html();
console.log(brand)
$(this).closest('tr').remove();
parameter = parameter.filter(isItemOk);
function isItemOk(item) {
return item.brand != brand;
}
console.log(parameter)
});
How can I delete a particular brand and corresponding categories from the parameter dictionary which contains more than one key value pairs of brand and categories?