This post will discuss how to remove the first character from a string in JavaScript.

Since strings are immutable in JavaScript, we can’t in-place remove characters from it. The idea is to create a new string instead. There are three ways in JavaScript to remove the first character from a string:

1. Using substring() method

The substring() method returns the part of the string between the specified indexes or to the end of the string.

Download  Run Code

 
You can easily extend the solution to remove the first n characters from the string.

Download  Run Code

2. Using slice() method

The slice() method extracts the text from a string and returns a new string.

Download  Run Code

 
This can be easily extended to remove first n characters from the string.

Download  Run Code

3. Using substr() method

The substr() method returns a portion of the string, starting at the specified index and extending for a given number of characters or until the string’s end.

Download  Run Code

 
Note that substr() might get deprecated in the future and should be avoided.

That’s all about removing the first character from a string in JavaScript.