Sep

14

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

Comments

Name (required)

Email (required)

Website

Speak your mind

1 Comment so far

  1. deesh1531982 on September 17, 2008 8:25 am

    Brilliant!

Sponsors




Links