JS案例:通过Object类创建对象示例

来自CloudWiki
跳转至: 导航搜索
<!doctype html>
<html>
<head>
	<meta chaeset="utf8">
	<title></title>
</head>

<body>
	
	<script type="text/javascript">
	    var animal = new Object();
		animal.name = "花花";
		animal.owner = "王小丽";
		animal.color = "黑色";
		document.write(animal.owner+"家的小狗的名字叫" + animal.name+",颜色是"+animal.color+"的");
	</script>

</body>
</html>