JavaScript 配列の最後の要素 取得

created 2021/10/04updated 2021/10/14
js
let lastElement = array.slice(-1)[0]; // or let lastElement = array[array.length - 1];