对象属性继承方法。
call(this,属性1,属性2)
函数的方法继承,原型(for循环)
for(att in obj.prototype)
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
</head>
<body>
<script>
function person(name,sex){
console.log("aaa");
this.name=name;
this.sex=sex;
}
person.prototype.showname = function(){
console.log("你好,我叫"+this.name);
}
function star (name,sex,job){
console.log("bbb");
person.call(this,name,sex);
this.job = job;
}
function extend(obj1,obj2){
for(attr in obj2){
obj1[attr] = obj2[attr];
}
}
extend(star.prototype,person.prototype);
star.prototype.showjob = function(){
console.log("ccc")
}
console.log(person)
var s1 = new star("黄晓明","男","演员");
s1.showname();
</script>
</body>
</html>