Check out example codes for "last element from list javascript". It will help you in understanding the concepts better.

Code Example 1

const lastItem = colors[colors.length - 1]

Code Example 2

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

Code Example 3

var my_array = /* some array here */;
var last_element = my_array[my_array.length - 1];

Learn ReactJs, React Native from akashmittal.com