Check out example codes for "last element of an array". It will help you in understanding the concepts better.

Code Example 1

var arr = [1,2,3]
var lastelementofarr = [arr.length-1] //I think it will return the last element in the array

Code Example 2

var animals = ['monkey', 'lion', 'don', 'frog', 'cow'];

var lastobject = animals[animals.length - 1];
	
	document.write('Last Element of array:-'+ lastobject );
	console.log(lastobject );

Code Example 3

.slice(-1)[0]

Code Example 4

var colors = ["red","blue","green"];
var green = colors[colors.length - 1]; //get last item in the array

Code Example 5

var colors = ["red","blue","green"];
var green = colors[colors.length - 1];//get last item in the array

Code Example 6

int[] array = {1,2,3};
System.out.println(array[array.length - 1]);

Learn ReactJs, React Native from akashmittal.com