DaniWeb IT Discussion Community

DaniWeb IT Discussion Community (http://www.daniweb.com/forums/index.php)
-   HTML and CSS (http://www.daniweb.com/forums/forum143.html)
-   -   restore default (built-in) function after overriding (http://www.daniweb.com/forums/thread73430.html)

sultanwadood Mar 26th, 2007 9:51 am
restore default (built-in) function after overriding
 
Hi all.
I need to know how to restore or roll back to built-in function after overriding like following example.
String.prototype.substr= function()
{ return "";}
Now I want to use the one already built-in.
I shall be very thankful if some one could help me.
Sultan Wadood

sultanwadood Mar 26th, 2007 10:33 am
call built-in from overridden function of Object in javascript
 
Hi All.
Do any body know how to call built in function of object like substr from overridden version. I am trying following example but the function called itself recursively not the function being overridden.
String.prototype.substr= function(str)
{

return str.substr(0,5);
}

I shall be very thankful if some one could give me some hints.
Sultan Wadood.

digital-ether Mar 27th, 2007 12:07 pm
Re: restore default (built-in) function after overriding
 
I don't think its possible to revert to the old function unless you save it somewhere.

eg:

String.prototype._substr = String.prototype.substr;

String.prototype.substr= function()
{

return this._substr(0,5);
}

sultanwadood Mar 28th, 2007 3:57 am
Re: restore default (built-in) function after overriding
 
my all poste problems have been solved.
thanks for helping and your valuable time.
Sultan Wadood.


All times are GMT -4. The time now is 4:33 pm.

Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2009 DaniWeb® LLC