javascript remove the first letter of string code example

Example 1: remove first 3 characters from string javascript

var string = "abcd";
console.log(string.substring(3)); //"d"

Example 2: javascript remove first character from string

let str = " hello";
str = str.substring(1);

Example 3: trim first character in javascript

let str = 'Hello';
 
str = str.slice(1);
console.log(str);
 
/*
    Output: ello
*/

Example 4: 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"

Example 5: js remove first element from string

let str = " hello"
str = str.substring(1)

Tags:

Java Example