get last value javascript code example
Example 1: 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
Example 2: get last element in array in javascript
arr.slice(-1)[0]