Code
<script type="text/ecmascript">
function construct(name, val) {
this[name] = val;
}
function student(name, age, grade, father, mother) {
this.constructor = construct;
this.name = name,
this.age = age;
this.grade = grade;
this.parents = new parents(father, mother);
}
function parents(father, mother) {
this.father = father;
this.mother = mother;
}
var student1 = new student("Joe", 16, 85, "Mark", "Stacy");
student1.constructor("boyfriend", "Tom");
</script>
the rusult of student1
Code
student1
{}
age: 16
boyfriend: "Tom"
grade: 85
name: "Joe"
parents: {}
posted @
2009-01-18 12:22
.net's
阅读(
319)
评论()
编辑
收藏
举报