原型对象与原型链

知道类和继承,理解起来不难,多去敲敲。
<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>Document</title>
</head>
<body>
<span>sssss</span>
<script type="text/javascript">
console.log(Number);
console.log(typeof Number);//function
console.log(Number.prototype);//Number {constructor: function, toExponential: function, toFixed: function, toPrecision: function, toString: function…
console.log(Object);//function Object() { [native code] }
console.log(Object.prototype);
console.log('-------------字面量对象');
var a = {};
console.log(a);//
console.log(a.prototype);//undefined
console.log(Object.prototype);//同下
console.log(a.__proto__); //同上Object {__defineGetter__: function, __defineSetter__: function, hasOwnProperty: function, __lookupGetter__: function, __lookupSetter__: function…}
console.log('------------------构造函数');
var person = function(){
	this.name = '小明';
	this.show = function(){

	};
};
var stu = new person();
console.log(Function.prototype);
console.log(person.__proto__);//function () { [native code] }
console.log(person.prototype);//object{constructor:function,__proto__:object}
console.log(stu.prototype);//undefined 只有函数是有prototype
console.log(stu.__proto__);//同上上
console.log(stu);
console.log('--------------小实例');
Object.prototype.show = function(){
	console.log('我给自己添加了一个show方法');
	this.author = '高亚丽';
}
var b = {};
b.show(); //我给自己添加了一个show方法
console.log(b.author);//高亚丽
console.log(Object.prototype);
</script>	
</body>
</html>
我的图解:



  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值