よくあるのは
const list = [1,2,3,4,5];
const lastValue = list[list.length - 1];だが、そもそも上記の例でのlistを定義せずよしなにしたいケースが発生した
- org/repoの文字列からリポジトリ名のみを抜き出すケース
const path = 'hoge/fuga';
const repo = path.split('/').pop(); // fugaES2022を使えるならatで良い
const path = 'hoge/fuga';
const repo = path.split('/').at(-1); // fuga参考
javascript - Getting the last element of a split string array - Stack Overflow


