1) Two methods to find last element of an array
// last element in an array
// 0 1 2 3 4 5
const arr = ['A', 'B', 'C', true, 20, 'xyz'];
// 1st method
console.log(arr[5]); // A
// 2nd mehod
console.log(arr[arr.length - 1]); // arr[6-1] => arr[5]
===============================================================================================
TERMINAL:
Comments
Post a Comment