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,631
  • 4
  • 27
  • 49
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
  • 44,706
  • 42
  • 157
  • 243