If the array position is not fixed, then how we remove the array ? I mean not using index/position. May be by using for loop. Position of the array is not fixed.
-
You have answered yourself ... for loop. Google javascript for loop and you will get plenty of examplesGuanxi– Guanxi2015-05-05 09:38:07 +00:00Commented May 5, 2015 at 9:38
-
You do not show any efford that you've tryed to search over internet. stackoverflow.com/questions/9882284/…Marin Takanov– Marin Takanov2015-05-05 09:39:37 +00:00Commented May 5, 2015 at 9:39
3 Answers
This sounds like a duplicate, if you want to remove an item from an array, in the loop you need to do check on if say the BankBranchId == 6, if it is the you want to remove the object from the array.
Which is shown here -
Comments
Use splice to remove elements from an array, how to determine what is to be deleted. I think your BankBranchId is unique, so here it goes.
var removeBBID = 6;
for(key in bankBranchReponse) {
if(bankBranchReponse[key].BankBranchId == removeBBID) {
bankBranchReponse.splice(key, 1);
break;
}
}
2 Comments
removeBBID is the BankBranchId value, within the object.I agree with the link what @JessicPartridge has given as her answer and what and @KBN has mentioned in his answer but there checking is happening on only one value of array!! Below code checks all the value and then removes array object from list!
for(var i=0;i<bankBranchReponse.length;i++)
{
if(bankBranchReponse[i].BankBranchId === removeVariable.BankBranchId &&
bankBranchReponse[i].BankBranchName===removeVariable.BankBranchName &&
bankBranchReponse[i].isPaymentMade===removeVariable.isPaymentMade)
{
bankBranchReponse.pop(bankBranchReponse[i]);
}
}