faqts : Computers : Programming : Languages : JavaScript : Language Core : prototypes/inheritance

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

8 of 10 people (80%) answered Yes
Recently 8 of 10 people (80%) answered Yes

Entry

How can i get function code when Function.prototype.toString method is overrided ?

Oct 11th, 2002 00:36
Thor Larholm, Dario Copia,


Before overriding the toString method, store a reference to it.
Function.prototype._toString = Function.prototype.toString;
Function.prototype.toString = function(){
  return 'overridden';
}
function a(){
  var b;
}
alert( a ) // displays 'overriden';
alert( a._toString() ); // displays the function source