惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

P
Palo Alto Networks Blog
P
Proofpoint News Feed
GbyAI
GbyAI
Microsoft Azure Blog
Microsoft Azure Blog
B
Blog
Google DeepMind News
Google DeepMind News
N
Netflix TechBlog - Medium
Recorded Future
Recorded Future
M
MIT News - Artificial intelligence
罗磊的独立博客
J
Java Code Geeks
月光博客
月光博客
F
Full Disclosure
博客园 - 聂微东
人人都是产品经理
人人都是产品经理
U
Unit 42
WordPress大学
WordPress大学
A
About on SuperTechFans
C
Cyber Attacks, Cyber Crime and Cyber Security
SecWiki News
SecWiki News
Security Latest
Security Latest
C
Check Point Blog
C
CERT Recently Published Vulnerability Notes
小众软件
小众软件
I
InfoQ
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
B
Blog RSS Feed
V
Visual Studio Blog
博客园_首页
NISL@THU
NISL@THU
I
Intezer
Spread Privacy
Spread Privacy
AWS News Blog
AWS News Blog
The Register - Security
The Register - Security
D
Darknet – Hacking Tools, Hacker News & Cyber Security
Latest news
Latest news
Project Zero
Project Zero
博客园 - 叶小钗
C
Cybersecurity and Infrastructure Security Agency CISA
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
P
Privacy International News Feed
博客园 - 【当耐特】
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
T
Threat Research - Cisco Blogs
Simon Willison's Weblog
Simon Willison's Weblog
T
Tor Project blog
V
Vulnerabilities – Threatpost
博客园 - 司徒正美
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
雷峰网
雷峰网

博客园 - MK2

cnpmcore 超大 JSON parse 性能优化 基于 Postgres 实现一个 Job Queue Graceful exit with cluster and pm Use Blanket.js instead of jscover 使用 connect-domain 捕获异步调用中出现的异常 Defense hash algorithm collision 防御hash算法冲突导致拒绝服务器 fibonacci(40) benchmark [nodejs]保证你的程序死了还能复活:forever and forever webui [nodejs]Buffer vs String Nodejs "Hello world" benchmark npm 资源库镜像 NodeBlog v0.2.0 更新说明 NAE支持自定义域名了 Nodejs 离线文档下载 nodejs读写大文件 Nodejs HTTP请求的超时处理(Nodejs HTTP Client Request Timeout Handle) 在jQuery 1.5+ 的jqXHR上监听文件上传进度(xhr.upload) 关于Nodejs中Buffer释放的二三事 nodejs web开发入门: Simple-TODO Nodejs 实现版
关于__proto__的链式记忆
MK2 · 2011-11-02 · via 博客园 - MK2

实例化解析:

function Foo() {};

var foo = new Foo();
foo.__proto__ === Foo.prototype;
foo.__proto__.__proto__ === Object.prototype;
foo.__proto__.__proto__.__proto__ === null;
foo.prototype === undefined;
foo.toString === Object.prototype.toString;

原形继承后的实例化解析:

function Bar() {};

Bar.prototype.__proto__ = Foo.prototype;

var bar = new Bar();
bar.__proto__ === Bar.prototype;
bar.__proto__.__proto__ === Foo.prototype;
bar.__proto__.__proto__.__proto__ === Object.prototype;
bar.__proto__.__proto__.__proto__.__proto__ === null;
bar.prototype === undefined;
bar.toString === Object.prototype.toString

对象bar,访问toString,整个链式过程如下:

bar.toString 
    || bar.__proto__.toString 
    || bar.__proto__.__proto__.toString
    || bar.__proto__.__proto__.__proto__.toString 

bar.toString === Object.prototype.toString

最终调用的是 Object.prototype.toString

奇怪的Foo.toString

Foo.__proto__ === Function.prototype;
Foo.__proto__.__proto__ === Object.prototype;
Foo.prototype.__proto__ === Object.prototype;
// 神奇竟然不等于 Object.prototype.toString
Foo.toString === Object.toString;
Foo.prototype.toString === Object.prototype.toString;

每个function生成的时候都直接被设置了toString 等于 Object.toString了。

参考文档

有爱

希望本文对你有用 ^_^