The only change is id value at 0th object. You can see i entered it as 4. It will check the max value in array of objects for id. In this case, it is 3. So it will increment by 1 and put it as the id value for newly added row.

Can someone let me know how to achieve this please.

Also, I had one more query.

If my id values are as follows.

1
2
3
4
5
6

And i delete 4 and 5. So new rows will be

1
2
5
6

Here, it will check max length as 4 and add id value of 5 to newly row. it will look somewhat like this.

5
1
2
5
6

In this case, 5 is repeated. I dont want this. I instead would like to see which is the highest value given to id, and then increment the id according to it. So it should look like this.