Using the Prototype property of each object in JavaScript We can add our own methods and properties to the built-in objects in JavaScript. Here we use this property to add three methods for String objects: TRIM, LTRIM, RTRIM (the same function as the same name in VBScript) String.Prototype.trim = function () {Return this.Replace (/ (^ / s) *) | (/ s * $) / g, ""); String.Prototype.ltrim = function () {Return this.Replace (/ (^ / S *) / g, "");} String.Prototype .Rtim = function () {Return this.Replace (/ (/ s * $) / g, "");} how, simple, look at an instance of use: