JavaScript - Delete Character from JS String Last Updated : 21 Nov, 2024 Summarize Comments Improve Suggest changes Share Like Article Like Report In JavaScript, characters can be deleted from the beginning, end, or any specific position in a string. JavaScript provides several methods to perform these operations efficiently.Delete First CharacterTo remove the first character from a string, we can use methods like slice, substring, or regular expressions.Example (Using slice): JavaScript let str = "Hello GFG"; let result = str.slice(1); // Removes the first character console.log(result); Outputello GFG You can delete the character from the beginning of the given string using many other methods, refer to this article for more Methods.Delete Last CharacterTo delete the last character from a string, methods like slice or substring are commonly used.Example (Using slice): JavaScript let str = "Hello GFG"; let result = str.slice(0, -1); // Removes the last character console.log(result); OutputHello GF You can delete the character from the end of the given string using many other methods, refer to this article for more Methods.Delete Character at a Specific PositionTo remove a character from a specific position, split the string into parts before and after the position and concatenate them.Example (Using slice): JavaScript let str = "Hello GFG"; let position = 5; let result = str.slice(0, position) + str.slice(position + 1); console.log(result); OutputHelloGFG You can delete the character from the end of the given string using many other methods, refer to this article for more Methods.Delete All Occurrence of a Character Delete the given character's occurrence from the given string and print the new string. Example (Regular Expression): JavaScript let str = "Geeks-for-Geeks"; let ch = "-"; let regex = new RegExp(ch, 'g'); let res = str.replace(regex, ''); console.log(res); OutputGeeksforGeeks You can delete all occurrence of character from the given string using many other methods, refer to this article for more Methods. Comment More infoAdvertise with us Next Article JavaScript - How To Get The Last Caracter of a String? M meetahaloyx4 Follow Improve Article Tags : JavaScript Web Technologies javascript-string JavaScript-String-Questions Similar Reads JavaScript - Delete First Character of a String To delete the first character of a string in JavaScript, you can use several methods. Here are some of the most common onesUsing slice()The slice() method is frequently used to remove the first character by returning a new string from index 1 to the end.JavaScriptlet s1 = "GeeksforGeeks"; let s2 = s 1 min read JavaScript - Insert Character in JS String In JavaScript, characters can be inserted at the beginning, end, or any specific position in a string. JavaScript provides several methods to perform these operations efficiently.At the BeginningTo insert a character at the beginning of a string, you can use string concatenation or template literals 1 min read Remove a Character From String in JavaScript In JavaScript, a string is a group of characters. Strings are commonly used to store and manipulate text data in JavaScript programs, and removing certain characters is often needed for tasks like:Removing unwanted symbols or spaces.Keeping only the necessary characters.Formatting the text.Methods t 3 min read JavaScript - Delete Character at a Given Position in a String These are the following ways to Delete Character at a Given Position in a String:1. Using slice() MethodThe slice() method allows you to extract portions of a string. By slicing before and after the target position, you can omit the desired character.JavaScriptlet str = "Hello GFG"; let idx = 5; let 1 min read JavaScript - How To Get The Last Caracter of a String? Here are the various approaches to get the last character of a String using JavaScript.1. Using charAt() Method (Most Common)The charAt() method retrieves the character at a specified index in a string. To get the last character, you pass the index str.length - 1.JavaScriptconst s = "JavaScript"; co 3 min read JavaScript - How to Get Character Array from String? Here are the various methods to get character array from a string in JavaScript.1. Using String split() MethodThe split() Method is used to split the given string into an array of strings by separating it into substrings using a specified separator provided in the argument. JavaScriptlet s = "Geeksf 2 min read Like