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??
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??
You can get the total length of an array by using length
.
array[array.length-1]