Sep
14
JavaScript - Remove the Last Character of a String
September 14, 2008 |
To remove the last character of a string can be easily done by combining some build-in JavaScipt functions.
var str = 'hullo world!'; var newStr = str.substring(0, str.length-1); alert(newStr); // alert hullo world
In the above example, you got a string ‘hullo world!’, the newStr subtract the string, take the character range from the first to the one before the last, and you will get the new string newStr ‘hullo world’.
Enjoy!
Similar Posts
- Prototype Function Variable inside Observe
- JavaScript - Get Form Checkbox Array Values
- JavaScript Convert CSV to Array
- JavaScript Control Flash Replay
- Prototype Drop Down Menu
- Mootools Prevent Ajax Request Cache
- JavaScript Stop a Loop
- JavaScript - Ways to Create Markup
- JavaScript - Unobtrusive Slideshow
Comments
1 Comment so far



































Brilliant!