Wednesday, January 19, 2011

Javascript:Remove the last character in a string

var str = 'Dear Raj!';
var newStr = str.substring(0, str.length-1);
//alert(newStr); 
but the simplest is
str.slice(0,-1) 

No comments:

Post a Comment