Como obter o último caminho da URL em JavaScript

const lastSegmentOfUrl = this.href.substring(this.href.lastIndexOf('/') + 1);
Anxious Alligator