typescript last element of array code example
Example 1: how to get last element of array in typescript
var items: String[] = ["tom", "jeff", "sam"];
alert(items[items.length-1])
Example 2: how to get the last element in javascript
const nums = [1, 2, 3, 4, 5, 6, 7];
const lastOne = nums[nums.lenght - 1]; // last element of array