SOURCE

console 命令行工具 X clear

                    
>
console
function Person (name) {
    this.name = [name]
}

Person.prototype.getName = function () {
    return this.name
}

function Child (name) {
    Person.call(this, name)
}

Child.prototype = new Person()
Child.prototype.constructor = Child


var child1 = new Child('赵云')
child1.name[0] = '张飞'
var child2 = new Child('赵云')

console.log(child1.name)
console.log(child2.name)
console.log(child2.getName())

// 既继承了父类的实例属性也继承了父类的原型属性 
// 缺点: 每一次new一个子类时, 都会去new一个父类的实例
<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<meta name="viewport" content="width=, initial-scale=">
	<meta http-equiv="X-UA-Compatible" content="">
	<title>组合式继承</title>
</head>
<body>
	
</body>
</html>