参考:http://stackoverflow.com/questions/650764/how-does-proto-differ-from-constructor-prototype

http://blog.rainy.im/

__proto__ is the actual object that is used in the lookup chain to resolve methods, etc. prototype is the object that is used to build __proto__ when you create an object with new:

( new Foo ).__proto__ === Foo.prototype
( new Foo ).prototype === undefined

The most surprising thing for me was discovering that Object.__proto__ points to Function.prototype, instead of Object.prototype, but I'm sure there's a good reason for that :-)

I think the class Object itself is an instance of Function, that's why Object.__proto__ === Function.prototype.

The reason why Object.__proto__ points to Function.prototype is because Object() by itself is a native function that instantiates an empty object. Therefore, Object() is a function. You'll find that all the other major native types' __proto__ properties point to Function.prototypeObjectFunctionStringNumber, and Array all inherit the Function prototype.

This means that adding to Function.prototype will automatically reflect on all objects whose __proto__ is referencing the Function.prototype.

For example, look the map below:

Furthermore, even the class Function itself is an instance of Function itself, that is Function.__proto__ === Function.prototype, that's also why Function === Function.constructor

Further furthermore, the regular class Cat is an instance of Function, that is Cat.__proto__ === Function.prototype.

The reason for the above is, when we create a class in JavaScript, actually, we are just creating a function, which should be an instance of FunctionObject and Function are just special, but they are still classes, while Cat is a regular class.

As a matter of factor, in Google Chrome JavaScript engine, the following 4:

  • Function.prototype
  • Function.__proto__
  • Object.__proto__
  • Cat.__proto__

They are all === (absolutely equal) to the other 3, and their value is function Empty() {}

> Function.prototype
function Empty() {}
> Function.__proto__
function Empty() {}
> Object.__proto__
function Empty() {}
> Cat.__proto__
function Empty() {}
> Function.prototype === Function.__proto__
true
> Function.__proto__ === Object.__proto__
true
> Object.__proto__ === Cat.__proto__
true prototype-chain

js中Object.__proto__===Function.prototype的更多相关文章

  1. JS 中的 __proto__ 、prototype、constructor

    首先 先解释这三个属性: (1) prototype  : 它是函数独有的,从一个函数指向一个对象(函数的原型),含义是函数的原型对象,也就是这个函数所创建的实例的原型对象.(普通函数的该属性没有作用 ...

  2. Javascript中的__proto__、prototype、constructor

    今天重温了下Javacript,给大家带来一篇Javascript博文,相信对于Javacript有一定了解的人都听过prototype原型这个概念,今天我们深度的分析下prototype与__pro ...

  3. javascript中的__proto__和prototype

    一.2个参考网址: http://icekiller110.iteye.com/blog/1566768 http://www.cnblogs.com/snandy/archive/2012/09/0 ...

  4. js的Object和Function

    自己闲的没事干,自己想通过js的了解写一个Function和Object之间的关系,可以肯定的是我写错了,但是希望可以有所启发. Function和Object Function.__proto__ ...

  5. 【JavaScript】关于JS中的constructor与prototype

    最初对js中 object.constructor 的认识: 在学习JS的面向对象过程中,一直对constructor与prototype感到很迷惑,看了一些博客与书籍,觉得自己弄明白了,现在记录如下 ...

  6. 【推荐】关于JS中的constructor与prototype【转】

    最初对js中 object.constructor 的认识: 在学习JS的面向对象过程中,一直对constructor与prototype感到很迷惑,看了一些博客与书籍,觉得自己弄明白了,现在记录如下 ...

  7. js中Object.defineProperty()和defineProperties()

    在介绍js中Object.defineProperty()和defineProperties()之前,我们了解下js中对象两种属性的类型:数据属性和访问器属性. 数据属性 数据属性包含一个数据的位置, ...

  8. js中的constructor 和prototype

    参考 http://www.cnblogs.com/yupeng/archive/2012/04/06/2435386.html function a(c){ this.b = c; this.d = ...

  9. js in depth: arrow function & prototype & this & constructor

    js in depth: arrow function & prototype & this & constructor https://developer.mozilla.o ...

随机推荐

  1. 实现类似QQ自拍头像的功能(demo源码)

    在很多软件系统中,都允许用户设置自己的头像,甚至可以直接使用摄像头照相作为自己的头像,就像QQ的自拍头像功能一样. 这种功能是如何实现的了?最直接的,我们可以使用Windows提供的VFW技术或Dir ...

  2. Excel教程(9) - 信息函数

    CELL   用途:返回某一引用区域的左上角单元格的格式.位置或 内容等信息,该函数主要用于保持与其它电子表格程序的兼容 性. 语法:CELL(info_type,reference) 参数:Info ...

  3. digitalocean优惠码30美元1G内存VPS免费使用两个月

    著名的云主机服务商CloudWays送福利啦!CloudWays是一家云主机网站服务商,与Digitalocean和亚马逊AWS开展合作,新用户注册验证手机即可赠送价值30美元的免费VPS主机. 申请 ...

  4. StretchBlt 提高图片显示质量的方法

    通过SetStretchMode(STRETCH_HALFTONE)实现,同时注意重新设置画刷起点 LRESULT CMainDlg::OnPaint(UINT uMsg, WPARAM wParam ...

  5. Openjudge-计算概论(A)-过滤多余的空格

    描述: 一个句子中也许有多个连续空格,过滤掉多余的空格,只留下一个空格. 输入一行,一个字符串(长度不超过200),句子的头和尾都没有空格.输出过滤之后的句子. 样例输入 Hello world.Th ...

  6. go语言实现寻找最大子数组

    题目:给定一个数字序列,寻找其中各元素相加和最大的子数组 /* 寻找最大子数组go语言实现 */ package main import fmt "fmt" func main() ...

  7. .net dynamic动态加属性

    class Test : System.Dynamic.DynamicObject { public override bool TryGetMember(System.Dynamic.GetMemb ...

  8. 解决ie阴影的兼容性

    box-shadow:0px 0px 10px #aba25b; -webkit-box-shadow:0px 0px 10px #aba25b; -moz-box-shadow:0px 0px 10 ...

  9. html5学习(一) video字段

    html5对视频的支持: html5通过<video></video>字段实现web页面上视频的播放功能. 目前各大浏览器对<video>字段的支持: 当前,vid ...

  10. C# 除法的细节

    最近在做项目时有个地方用到了概率,要计算概率自然会用到除法.我这边概率的算法是这样的,从0到10000获取个随机数,随机值除以10000就是概率了,但是一时大意没注意细节,结果直接除了,如下: 查询结 ...