// Menggunakan Prototype
String.prototype.trim = function() { return this.replace(/^\s+|\s+$/g,""); } String.prototype.ltrim = function() { return this.replace(/^\s+/,""); } String.prototype.rtrim = function() { return this.replace(/\s+$/,""); } // example of using trim, ltrim, and rtrim var myString = " hello my name is "; alert("*"+myString.trim()+"*"); alert("*"+myString.ltrim()+"*"); alert("*"+myString.rtrim()+"*");
0 komentar:
Posting Komentar