JavaScript split dapatkan elemen terakhir
a = "hello.dear.friends"
a.split(".").pop()
> "friends"
Cerbrain
a = "hello.dear.friends"
a.split(".").pop()
> "friends"
var id = "ctl03_Tabs1";
var lastFive = id.substr(id.length - 5); // => "Tabs1"
var lastChar = id.substr(id.length - 1); // => "1"
const str = "hello, how are you today?"
const last = str..slice(-1)[0]
console.log({last})
Run code snippetHide results