VOOZH about

URL: https://www.geeksforgeeks.org/javascript/javascript-add-a-character-to-the-beginning-of-a-string/

⇱ JavaScript - Add a Character to the Beginning of a String - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

JavaScript - Add a Character to the Beginning of a String

Last Updated : 23 Jul, 2025

These are the following ways to insert a character at the beginning of the given string:

1. Using String Concatenation

Directly prepend the character using the + operator or template literals.


Output
*Hello, World!

2. Using Template Literals

String concatenation using + or template literals is an effective way to insert a character at the beginning of a string. This method creates a new string with the desired modification without altering the original string (since strings are immutable in JavaScript).


Output
*Hello, World!

3. Using slice() Method

Extract the original string and append the new character to it by the use of slice() method.


Output
*Hello, World!

4. Using Using splice() Method (Array-Based)

Convert the string to an array (as strings are immutable in JavaScript), use splice to insert the character at the beginning, and join it back into a string.


Output
*Hello, World!
Comment