【JS】利用函数构建对象

Osinghong2个月前 (04-14)成果展示62
<!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】简易百度4个月前 (02-24)
【JS】IF ELSE语句3个月前 (03-10)
【JS】For语句进阶3个月前 (03-24)
【JS】关于continue3个月前 (03-24)
【JS】循环嵌套3个月前 (03-24)