var member = "my name is Mate";
var last2 = member.slice(-2);
alert(last2); // "te"
'abc'.slice(-1); // c
// Get last n characters from string
var name = 'Shareek';
var new_str = name.substr(-5); // new_str = 'areek'
str.charAt(str.length-1)
const myString = "linto.yahoo.com.";
const stringLength = myString.length; // this will be 16
console.log('lastChar: ', myString.charAt(stringLength - 1)); // this will be the string
Run code snippet