JavaScript - Add a Character to the End of a String Last Updated : 20 Nov, 2024 Summarize Comments Improve Suggest changes Share Like Article Like Report These are the following ways to insert a character at the end of the given string:1. Using ConcatenationWe can use the + operator or template literals to append the character. JavaScript let str = "Hello GFG"; let ch = "!"; let res = str + ch; console.log(res); OutputHello GFG! 2. Using Template LiteralsString concatenation using + or template literals is an effective way to insert a character at the end of a string. This method creates a new string with the desired modification without altering the original string (since strings are immutable in JavaScript). JavaScript let str = "Hello, World!"; let ch = "*"; let res = `${str}${ch}`; console.log(res); OutputHello, World!* 3. Using slice() Method The slice method to extract the original string and append the new character. JavaScript let str = "Hello GFG"; let ch = "!"; // Slices the entire string and appends the character let res = str.slice(0) + ch; console.log(res); OutputHello GFG! 4. Using Using splice() Method (Array-Based)Convert the string to an array, use splice to insert the character, and join the array back into a string. JavaScript let str = "Hello GFG"; let ch = "!"; // Convert string to array let arr = str.split(""); // Insert character at the end arr.splice(arr.length, 0, ch); // Convert array back to string let res = arr.join(""); console.log(res); OutputHello GFG! Comment More infoAdvertise with us Next Article JavaScript - Add a Character to the End of a String M meetahaloyx4 Follow Improve Article Tags : JavaScript Web Technologies javascript-string Similar Reads JavaScript - Add a Character to the Beginning of a String These are the following ways to insert a character at the beginning of the given string:1. Using String ConcatenationDirectly prepend the character using the + operator or template literals.JavaScriptlet str = "Hello, World!"; let ch = "*"; let res = ch + str; console.log(res); Output*Hello, World! 2 min read JavaScript - Add Characters to a String Here are the various approaches to add characters to a string in JavaScriptUsing the + Operator - Most PopularThe + operator is the simplest way to add characters to a string. It concatenates one or more strings or characters without modifying the original string.JavaScriptconst s1 = "Hello"; const 2 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 JavaScript - Delete Character from JS String 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 2 min read JavaScript - How to Pad a String to Get the Determined Length? Here are different ways to pad a stirng to get the specified length in JavaScript.1. Using padStart() MethodThe padStart() method can be used to pad a string with the specified characters to the specified length. It takes two parameters, the target length, and the string to be replaced with. If a nu 3 min read Like