代码如下呢
:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<script type="text/javascript">
/*
创建三个学生对象,并且输出学生的学号.姓名、年级和年龄(用对象构造函数进行构造)
*/
function Student(no,name,grade,age) {
this.no = no;
this.name = name;
this.grade = grade;
this.age = age;
}
var stu1 = new Student('1001','杨过','六年级','10');
console.log(stu1.no,stu1.name,stu1.grade,stu1.age);
var stu2 = new Student('1002','杨康','大三','23');
console.log(stu2.no,stu2.name,stu2.grade,stu2.age);
var stu3 = new Student('1003','杨题','高二','18');
console.log(stu3.no,stu3.name,stu3.grade,stu3.age);
</script>
</head>
<body>
</body>
</html>
运行截图: