【JS】利用函数构建对象

Osinghong6个月前 (04-14)成果展示99
<!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>


打赏
分享给朋友:

相关文章

【H5】表单11个月前 (11-27)
【H5】简易百度8个月前 (02-24)
【JS】三元表达式7个月前 (03-17)
【JS】For语句7个月前 (03-17)
【JS】For语句练习7个月前 (03-17)