参考: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. Vue - 使用命令行搭建单页面应用

    使用命令行搭建单页面应用 我们来看一下最后完成的效果: 大纲 1. 下载 node, git, npm 2. 使用命令行安装一个项目 一. 下载工具 node , git  的下载大家可以去官网自行下 ...

  2. ecshop里的$_CFG从哪来的

    以前经常有朋友问我, ecshop系统的$_CFG这个数组是从哪里来的,在哪里定义并赋值的.   下面就给大家说一下这个全局变量 $GLOBALS['_CFG']. ecshop里的 $_CFG数组主 ...

  3. 如何使用cygwin去编译cocos2dx项目中的C++文件

    将生成的cocos2dx的Android项目导入到eclipse 可以先测试一下如何编译C++项目: 1.打开cygwin,进入到Android项目对应的目录下面去: 2.编译脚本 在编译脚本之间,如 ...

  4. Python学习笔记_Chapter 7web开发

    1.web应用元素 a.成员: web浏览器 web服务器 b.行为: web请求: 请求内容: 静态内容:如html文件,图像. 动态内容:需服务器运行一个程序进而做出响应. 网关接口&CG ...

  5. windows网络编程(1)同步套接字

    1.socket是应用程序与网络驱动程序的桥梁,在应用程序中创建socket,将数据交付给socket即完成数据传输,剩下的任务由socket和网络驱动程序完成: 2.套接字类型:SOCK_STREA ...

  6. 参考C++STL标准库中对了的使用方法

    http://www.cppblog.com/zhenglinbo/archive/2012/09/18/191170.html 参考:http://www.cppblog.com/zhenglinb ...

  7. sql优化原则

    尽量使用性能高的比如left join等,尽量减少数据查询的column,尽量不要查询冗余数据,like的话“%%”是没有 办法使用索引的,但是“%”是可以使用索引的 having以前一直不知道到底真 ...

  8. ADO.NET基础、数据增删改查

    ADO.NET:数据访问技术,就是将C#和MSSQL连接起来的一个纽带.我们可以通过ADO.NET将内存中的临时数据写入到数据库中,也可以将数据库中的数据提取到内存中供程序调用. 数据库数据的增.删. ...

  9. 可写的计算监控(Writable computed observables)

    新手可忽略此小节,可写依赖监控属性真的是太advanced了,而且大部分情况下都用不到. 一般情况下,计算监控的值是通过其他监控属性的值计算出来的,因此它是只读的.这个看似很奇怪,我们有什么办法可以让 ...

  10. MySql - JdbcType - Oracle类型映射

    MySql - JdbcType - Oracle类型映射   MySQL数据类型 JDBC TYPE Oracle数据类型 BIGINT BIGINT NUMBER(20) TINYINT TINY ...