Every time I used splice()
method to add new objects to array it will become like this:
[[{"id": 2, "text": "zebra"}]]
and if I use pop()
method I can't choose an object I want by index. Any solution?
Every time I used splice()
method to add new objects to array it will become like this:
[[{"id": 2, "text": "zebra"}]]
and if I use pop()
method I can't choose an object I want by index. Any solution?
splice()
changes the original array whereas slice()
doesn't but both of them returns array object.
Refer this : JavaScript Array splice vs slice