at(-1), and the last element without a length calculation

Negative indexing on arrays and strings, which every other language has had and JavaScript expressed as an arithmetic expression.

const parts = path.split('/')

parts[parts.length - 1]      // and the bug when parts is empty
parts.at(-1)                 // undefined, cleanly

'hello'.at(-1)               // 'o'

// it does NOT work on the bracket syntax:
parts[-1]                    // undefined, always — that is a
                             // property named "-1"

The bracket form silently returning undefined is why this is worth adopting rather than merely nicer — arr[-1] looks like negative indexing to anybody arriving from Python and is a property lookup that will never succeed. It works on arrays, strings and typed arrays, and not on NodeList or other array-likes.