SyntaxFix
Write A Post
Hire A Developer
Questions
Single statement that works with trailing slash. If you are using IE11 you'll have to polyfill the filter function.
filter
var name = window.location.pathname .split("/") .filter(function (c) { return c.length;}) .pop();