SOURCE

console 命令行工具 X clear

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

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

function Child () {
    
}

Child.prototype = new Person()

var child1 = new Child()
child1.name.push('张飞')
var child2 = new Child()

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

// 原型链式继承.子类的原型对象继承自父类的实例 缺点:父类中存在引用类型的数据,
// 多个子类实例的修改会互相影响, 无法向父类传参
<!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>