<!DOCTYPE html>
<html>
<head lang="en">
<meta charset="UTF-8">
<title></title>
</head>
<body>
</body>
</html>
<script>
function Person(name,age){ //构造函数
this.name = name;
this.age = age;
}
Person.prototype.showName = function () { //用的共同的父亲
alert("我的名字是:"+ this.name);
}
Person.prototype.showAge = function () {
alert("我的年龄是:"+ this.age);
}
var demo = new Person("好大发",22);
var demo1 = new Person("好大发",22);
demo.showName();
demo.showAge();
alert( demo.showName == demo1.showName); //true 用的共同的父亲
</script>