Syntax for creating your member functions in JavaScript
String.prototype.FunctionName = function()
{
// write your logic;
return 'return value';
}
You can convvert above mentioned ToAscii fuction as member function, Thats left for the readers for practice.
Here are some frequently used functions.
Examples:
1.Trim
String.prototype.Trim = function()
{
return this.replace(/^\s+|\s+$/g,"");
}
2.Ltrim
String.prototype.Ltrim = function()
{
return this.replace(/^\s+/,"");
}
3.Rtrim
String.prototype.rtrim = function()
{
return this.replace(/\s+$/,"");
}
Friday, July 13, 2007
Subscribe to:
Posts (Atom)