I have an array
0: {Premium: '18', ChangeType: 'REW', description: 'Replaced by Agent', TransDate: '2021-09-14 15:15:11', EffectiveDate: '2021-09-14', …}
1: {Premium: '19', ChangeType: 'XLN', description: 'Replaced by Agent', TransDate: '2021-09-14 15:10:45', EffectiveDate: '2021-09-14', …}
2: {Premium: '3', ChangeType: 'XLN', description: 'Replaced by Agent', TransDate: '2021-09-14 15:10:08', EffectiveDate: '2021-09-14', …}
3: {Premium: '19', ChangeType: 'XLN', description: 'Replaced by Agent', TransDate: '2021-09-14 15:09:43', EffectiveDate: '2021-09-14', …}
4: {Premium: '19', ChangeType: 'XLN', description: 'Replaced by Agent', TransDate: '2021-09-14 15:08:21', EffectiveDate: '2021-09-14', …}
5: {Premium: '19', ChangeType: 'XLN', description: 'ewqwe', TransDate: '2021-09-14 15:07:53', EffectiveDate: '2021-09-15', …}
6: {Premium: '198', ChangeType: 'XLN', description: 'Replaced by Agent', TransDate: '2021-09-14 15:01:01', EffectiveDate: '2021-09-14', …}
7: {Premium: '15', ChangeType: 'XLN', description: 'Replaced by Agent', TransDate: '2021-09-14 15:00:14', EffectiveDate: '2021-09-14', …}
8: {Premium: '19', ChangeType: 'XLN', description: 'Replaced by Agent', TransDate: '2021-09-14 14:59:08', EffectiveDate: '2021-09-14', …}
9: {Premium: '13', ChangeType: 'XLN', description: 'Replaced by Agent', TransDate: '2021-09-14 14:58:32', EffectiveDate: '2021-09-14', …}
10: {Premium: '11', ChangeType: 'XLN', description: 'Replaced by Agent', TransDate: '2021-09-14 14:57:14', EffectiveDate: '2021-09-14', …}
11: {Premium: '12', ChangeType: 'PCH', description: 'wewqe', TransDate: '2021-09-14 14:44:13', EffectiveDate: '2021-09-14', …}
12: {EntryDate: '9/14/2021', EffectiveDate: '2021-09-14', ChangeType: 'XLN', Premium: '19', description: 'Replaced by Agent', …}
I want to remove the last row from the array. I had used the pop() function but it returns only the last record rather than returning the full array except the last one.
Also, I had tried with the splice method like below.
policy_info.transactions.splice(policy_info.transactions.length - 1);
I could not get the result. Can anyone tell me what method to use with the array to achieve the result?
My Desired result is
0: {Premium: '18', ChangeType: 'REW', description: 'Replaced by Agent', TransDate: '2021-09-14 15:15:11', EffectiveDate: '2021-09-14', …}
1: {Premium: '19', ChangeType: 'XLN', description: 'Replaced by Agent', TransDate: '2021-09-14 15:10:45', EffectiveDate: '2021-09-14', …}
2: {Premium: '3', ChangeType: 'XLN', description: 'Replaced by Agent', TransDate: '2021-09-14 15:10:08', EffectiveDate: '2021-09-14', …}
3: {Premium: '19', ChangeType: 'XLN', description: 'Replaced by Agent', TransDate: '2021-09-14 15:09:43', EffectiveDate: '2021-09-14', …}
4: {Premium: '19', ChangeType: 'XLN', description: 'Replaced by Agent', TransDate: '2021-09-14 15:08:21', EffectiveDate: '2021-09-14', …}
5: {Premium: '19', ChangeType: 'XLN', description: 'ewqwe', TransDate: '2021-09-14 15:07:53', EffectiveDate: '2021-09-15', …}
6: {Premium: '198', ChangeType: 'XLN', description: 'Replaced by Agent', TransDate: '2021-09-14 15:01:01', EffectiveDate: '2021-09-14', …}
7: {Premium: '15', ChangeType: 'XLN', description: 'Replaced by Agent', TransDate: '2021-09-14 15:00:14', EffectiveDate: '2021-09-14', …}
8: {Premium: '19', ChangeType: 'XLN', description: 'Replaced by Agent', TransDate: '2021-09-14 14:59:08', EffectiveDate: '2021-09-14', …}
9: {Premium: '13', ChangeType: 'XLN', description: 'Replaced by Agent', TransDate: '2021-09-14 14:58:32', EffectiveDate: '2021-09-14', …}
10: {Premium: '11', ChangeType: 'XLN', description: 'Replaced by Agent', TransDate: '2021-09-14 14:57:14', EffectiveDate: '2021-09-14', …}
11: {Premium: '12', ChangeType: 'PCH', description: 'wewqe', TransDate: '2021-09-14 14:44:13', EffectiveDate: '2021-09-14', …}