- By Using .trim() method we can remove white spaces at both sides of a string.
- var str = " instanceofjava.com ";
- Will alert a popup with instanceofjava.com.
- str = str.replace(/,\s*$/, "");
- We can also use slice method to remove last character.
- To remove specific character from string in java script we can use
- var string = 'www.Instanceofjava.com';
- string.replace(/^www.+/i, ''); 'Instanceofjava.com'