繁体   English   中英

Douglas Crockford的书中关于Function.prototype的“方法”

[英]'method' on Function.prototype in Douglas Crockford's book

在Crockford的书中,“方法”被添加到Function.prototype

在我的浏览器控制台中,我做到了

  1. Function.method >未定义
  2. Function.prototype.method=function(name,func){this.prototype[name]=func; return this;} --> function(name,func){this.prototype[ame]=func; return this;}
  3. (function(){}).method --> function(name,func){this.prototype[name]=func; return this;}
  4. Function.method --> function(name,func){this.prototype[name]=func; return this;}

我可以理解步骤3,其中函数文字已定义“方法”

但是在步骤1中未定义的步骤4,Function.method中突然出现了已定义的“方法”。

Function是其自身的实例吗?

Function是其自身的实例吗?

是的

Function instanceof Function;
> true

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM