Web Tools Table Maker3schools TranslateImage CompressorFavicon Icon GeneratorCrop & Resize Image
Apu
Apu June 03, 2023 › #HowTo #Javascript

How to remove the first character from string in JavaScript

In the some cases, we have to remove the first character from a string . So,in this particular article, we will learn how to remove the first character from a string in javascript.

1. Using slice() method

Using the slice() method, we can easily remove the first character from a string. Not only the first character, we can also remove multiple characters from a single string. Just pass the value of how many characters you want to remove as a parameter. For example, I want to remove two characters.

Example of slice() method
  let myString = "Example of a string.";
  alert(myString.slice(2)) ;
  
Try it Yourself »

2. Using substring() method

Using the substring() method , we can also remove the characters from a string.

Example using substring() method
   let myString = "Example of a string.";
   document.write(myString.substring(3));
  
Try it Yourself »
save
listen
AI Answer
Write Your Answer
loading
back
View All