<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<title>Document</title>
</head>
<body>
</body>
<script type="text/javascript" >
// 通过call继承父级属性
function A(){
this.abc=12
}
function B(){
// this → new B();
A.call(this)
}
var obj = new B();
alert(obj.abc) //12
// 通过prototype继承父级方法
A.prototype.show=function(){
alert(this.abc)
}
B.prototype.show=A.prototype.show; //tongguo prototype原型继承父级方法
obj.show() //12
</script> </html>
原文:http://www.cnblogs.com/model-zachary/p/7435067.html