I bet you didn't know this. In a technical interview, you might be asked how to get the last element of an array. Well, there are three options, and you might like the last one best.
const latest = arr[arr.length - 1];const latest = arr.slice(-1)[0];And this one 😜
#JavaScript #FrontEnd #Developers #InterviewQuestions
const arr = [1, 2, 3, 4];
const latest = arr.at(-1);
console.log(latest); // 4