<!DOCTYPE html>
<html lang="en">
<head>
<meta name="applicable-device" content="mobile"/>
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
<meta charset="gb2312">
<title>nb</title>
<script type="text/javascript">
function nb(){
function dog(){
this.say=function(){
console.log("my name is "+this.name);
}
}
function dog1(){
this.name="hqc";
}
function dog2(){
this.name="lj";
}
dog1.prototype = new dog();//克隆
var hqc = new dog1();//会通过链式调用
hqc.say();
//dog2.prototype = new dog();
var lj = new dog2();
hqc.say.call(lj);
}
function nb2(){
function dog(){
this.name="hqc";
this.say=function(){
console.log("my name is "+this.name);
}
}
function dog2(){
this.name="lj";
}
var hqc = new dog();
hqc.say();
var lj = new dog2();
hqc.say.call(lj);
}
</script>
</head>
<body>
<div style="margin:0 auto;text-align:center;">
<div><span><a οnclick="nb()">nbnb</a></span></div>
<div><span><a οnclick="nb2()">nbnb2</a></span></div>
</div>
</body>
</html>