How to delete the first character of a string in JavaScript

Suppose you have a string and want to delete the first character in it.

How can you do this?

A simple solution is to useslice()Method through1As a parameter:

const text = 'abcdef'
const editedText = text.slice(1) //'bcdef'

Please noteslice()The method does not modify the original string.

It creates a new string, which is why it was assigned to the new variable in the example above.

Download mine for freeJavaScript beginner's manual


More js tutorials: