<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>js01_hello</title>
<meta name="author" content="Administrator" />
<script type="text/javascript">
function Parent(name) {
this.color = ["red","blue"];
this.name = name;
}
function Child(name,age) {
this.age = age;
/*
* 使用伪造的方式就可以把子类的构造函数参数传递到
* 父类中
*/
Parent.call(this,name);
}
var c1 = new Child("Leon",12);
var c2 = new Child("Ada",22);
alert(c1.name+","+c1.age);
alert(c2.name+","+c2.age);
</script>
</head>
<body>
</body>
</html>