How to remove leading comma from a string with JavaScript?

Sometimes, we want to remove leading comma from a string with JavaScript.

In this article, we’ll look at how to remove leading comma from a string with JavaScript.

How to remove leading comma from a string with JavaScript?

To remove leading comma from a string with JavaScript, we call string substring with 1.

For instance, we write

const myOriginalString = ",'first string','more','even more'";
const myString = myOriginalString.substring(1);

to call myOriginalString.substring with 1 to return a new string that’s the same as myOriginalString except that the first character is removed.

Conclusion

To remove leading comma from a string with JavaScript, we call string substring with 1.