<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
</head>
<body>
<script type="text/javascript">
//注册
function ShowDate(stus){
this.arr0=[];
this.loadInfo(stus);
}
//录入
ShowDate.prototype.loadInfo=function(arr){
for(var i in arr){
this.arr0.push(arr[i])
}
};
//输出
ShowDate.prototype.showInfo=function(stus){
this.arr0.forEach(function(item){
console.log(item.name,item.age,item.id);
});
};
//创建学生
function Student(id,name,age){
this.id=id;
this.name=name;
this.age=age;
}
var arr=[];
while(confirm('是否继续录入学生信息?')){
var id=prompt('请输入学生学号: ');
var name=prompt('请输入学生姓名: ');
var age=prompt('请输入学生年龄: ');
var stu=new Student(id,name,age);//创建学生对象
arr.push(stu);
}
//完成注册
var reg=new ShowDate(arr);//创建对象实例
reg.showInfo();
</script>
</body>
</html>