how to remove the first character of a string in javascript code example
Example 1: delete first character javascript
let str = 'Hello';
str = str.slice(1);
console.log(str);
/*
Output: ello
*/
Example 2: remove first 3 characters from string javascript
var string = "abcd";
console.log(string.substring(3)); //"d"
Example 3: javascript delete first character in string
var oldStr ="Hello";
var newStr = oldStr.substring(1); //remove first character "ello"
Example 4: remove first char javascript
let str = 'Hello';
str = str.substring(1);
console.log(str);
/*
Output: ello
*/
Example 5: how to remove first character from string in javascript
str = str.substring(1);
Example 6: js remove first character from string
// 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"