解析JavaScript对象间的关系

JavaScript里万物皆对象,但是对象之间的关系异常复杂和混乱,所以决定花时间把他们之间的核心关系搞清楚,并制作成图,分享出来,了解了这个图,再也不用买步步高点读机了,以下程序在ie11,chrome49,firfox46,opera37下都是true,ie10之前的ie版本访问__proto__会出错。啥也不说了,尽在图和代码中。



<!DOCTYPE HTML>

<html style="height: 100%">
<head>
<meta charset="utf-8">
</head>
<body style="height: 100%">
<!--<script type="text/javascript" src="jquery-2.2.3-unzip.js">-->
</script>
<script type="text/javascript" >
function x(){}
var y=new x();
z=new Object();
console.log(y.__proto__==x.prototype,"y.__proto__==x.prototype")
console.log(y.constructor==x,"y.constructor==x")
console.log(z.constructor==Object,"z.constructor==Object")
console.log(z.__proto__==Object.prototype,"z.__proto__==Object.prototype")
console.log(x.constructor==Function,"x.constructor==Function")
console.log(x.prototype.constructor==x,"x.prototype.constructor==x")
console.log(x.prototype.__proto__==Object.prototype,"x.prototype.__proto__==Object.prototype")
console.log(Object.constructor==Function,"Object.constructor==Function")
console.log(Object.prototype.constructor==Object,"Object.prototype.constructor==Object")
console.log(Object.prototype.__proto__==null,"Object.prototype.__proto__==null")
console.log(Function.constructor==Function,"Function.constructor==Function")
console.log((x.__proto__==Object.__proto__)&&(x.__proto__==Function.__proto__)&&(x.__proto__==Function.prototype)&&(Function.__proto__==Object.__proto__)&&(Function.prototype==Object.__proto__)&&(Function.__proto__==Function.prototype),"(x.__proto__==Object.__proto__)&&(x.__proto__==Function.__proto__)&&(x.__proto__==Function.prototype)&&(Function.__proto__==Object.__proto__)&&(Function.prototype==Object.__proto__)&&(Function.__proto__==Function.prototype)");


console.log(x.__proto__.prototype==undefined,"x.__proto__.prototype==undefined")
console.log(x.__proto__.__proto__==Object.prototype,"x.__proto__.__proto__==Object.prototype")
console.log(x.__proto__.constructor==Function,"x.__proto__.constructor==Function")




最后奉上我画了无数次才画成的手稿,纪念一下,原稿已经不知道哪去了,想想应该收藏起来的。











</script>
</html>
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值