JavaScript – Remove First Character of String

To remove first character of the given string in JavaScript, call slice() method on the string, and pass 1 as argument to it.

slice() method takes the starting position of the required resulting string as argument, and slices the string.

The syntax of the expression to remove the first character from the string str using slice() method is

str.slice(1)

slice() returns the resulting sliced string, and does not modify the original string.

Examples

In the following example, we take a string str, remove the first character using slice() method, and display the original and resulting string in pre#output.

index.html

ADVERTISEMENT

Conclusion

In this JavaScript Tutorial, we learned how to remove the first character of given string in JavaScript, using slice() method, with examples.