a = "hello.dear.friends"
a.split(".").pop()
> "friends"
let path = "/bar/foo/moo/";
let split = path.split("/");
let splicedStr = split.slice(0, split.length - 2).join("/") + "/";
console.log(splicedStr);
//outputs: /bar/foo/
const str = "hello, how are you today?"
const last = str..slice(-1)[0]
console.log({last})
Run code snippetHide results