1

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?

ABGR
  • 4,052
  • 2
  • 19
  • 42
Kuima Kui
  • 11
  • 2

1 Answers1

1

splice() changes the original array whereas slice() doesn't but both of them returns array object.

Refer this : JavaScript Array splice vs slice

Techie
  • 43,532
  • 40
  • 152
  • 238