var string = "abcd";
console.log(string.substring(3)); //"d"
let str = " hello";
str = str.substring(1);
let str = 'Hello';
str = str.substring(1);
console.log(str);
/*
Output: ello
*/
var s1 = "foobar";
var s2 = s1.substring(1);
alert(s2); // shows "oobar"
str = str.substring(1);
// Return a word without the first character
function newWord(str) {
return str.replace(str[0],"");
// or: return str.slice(1);
// or: return str.substring(1);
}
console.log(newWord("apple")); // "pple"
console.log(newWord("cherry")); // "herry"
let str = 'ass';
str = str.split(''); // (3) ["a", "s", "s"]
str.shift(); // (2) ["s", "s"]
str = str.join(''); // "ss"
let str = 'ss';
str = new RegExp('^.(.*)').exec(str)[1]; // "s"
let str = 's';
str = (function f(s) { // don't use on large strings
return s.length<=1?'':f(s.slice(0, -1))+s[s.length-1]
})(str); // ""