[英]'method' on Function.prototype in Douglas Crockford's book
In Crockford's book 'method' is added to Function.prototype 在Crockford的书中,“方法”被添加到Function.prototype
In my browser console, I did this 在我的浏览器控制台中,我做到了
Function.method
--> undefined Function.method
>未定义 Function.prototype.method=function(name,func){this.prototype[name]=func; return this;} --> function(name,func){this.prototype[ame]=func; return this;}
(function(){}).method --> function(name,func){this.prototype[name]=func; return this;}
Function.method --> function(name,func){this.prototype[name]=func; return this;}
I can understand step 3, where a function literal has 'method' defined 我可以理解步骤3,其中函数文字已定义“方法”
But how come in step 4, Function.method, which was undefined in step 1, suddenly has 'method' defined. 但是在步骤1中未定义的步骤4,Function.method中突然出现了已定义的“方法”。
Is Function an instance of itself ? Function是其自身的实例吗?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.