Let's say I do the following:
String.prototype.myFunc = function(){ /* code here */ }
I have just created a new method, myFunc
, that will be available for each string ( "This is a test".myFunc()
).
My question is: Is it possible, and if it is, how, to get the source code of myFunc
programatically? (This is inside Node)
您可以使用位于Function.prototype
上的toString
方法将函数作为字符串获取。
var funcSource = String.prototype.myFunc.toString();
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.