return last n items in array javascript code example
Example 1: javascript get last element of array
var foods = ["kiwi","apple","banana"];
var banana = foods[foods.length - 1]; // Getting last element
Example 2: how to get last element of array in typescript
var items: String[] = ["tom", "jeff", "sam"];
alert(items[items.length-1])