Hi,
On page 206, you provide a trim function to trim white space,
Code:
String.prototype.trim = function () {
var reExtraSpace = /^\s+(.*?)\s+$/;
return this.replace(reExtraSpace, "$1");
};
var sTest = " this is a test ";
alert("[" + sTest + "]"); //outputs ¡° [ this is a test ] ¡°
alert("[" + sTest.trim() + "]"); //outputs ¡° [this is a test]¡±
But if the being of string to be trimmed has no white space, like "this is a test ", the method can't trim white space in the end, vice versa. So how about to change reExtraSpace to /^\s*(.*?)\s*$/? so that it can do the real trim work? I don't know if it's right. It's just my advice.