加载中...

声明一个对象


调试运行

<html>
<head>
<title>声明一个对象</title>
</head>
<body>
<script language="javascript">
<!--
	function person(name,age){
		this.name = name;
		this.age  = age;
	}
	
	Jim = new person("Jim",20);
	document.write("Jim 的姓名是:",Jim.name,"<br>");
	document.write("Jim 的年龄是:",Jim.age,"<br>");

	Tom = new person();
	Tom.name = "Tom";	
	Tom.age  = 22;
	document.write("Tom 的姓名是:",Tom.name,"<br>");
	document.write("Tom 的年龄是:",Tom.age,"<br>");

//-->
</script>
</body>
</html>

还没有评论.