-5
object = [
{"id":1,"name":"Joe"}
{"id":2,"name":"Joe1"}
{"id":3,"name":"Joe2"}
{"id":4,"name":"Joe3"}
]

I want to select {"id":4,"name":"Joe3} but I can't do like object[3] so it there any way to retrieve the last object of an array??

1 Answers1

1

You can get the total length of an array by using length.

array[array.length-1]
bobthedeveloper
  • 3,733
  • 2
  • 15
  • 31