【JS】利用函数构建对象
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>d24c04429</title>
<meta name="viewport"
content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
</head>
<body>
<script>
function Student(name, age) {
this.name = name;
this.age = age;
this.introduce = function() {
console.log("大家好,我叫" + this.name + ",今年" + this.age + "岁");
};
}
var stu1 = new Student("欧永鸿", 18);
stu1.introduce();
</script>
</body>
</html>