<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>创建一个对象,其它一个属性是数组</title>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
</head>
<body>
<script type="text/javascript">
var p = {
id:1,
name:'哈哈',
home:['湘潭','长沙','广州']
};
for(var i=0;i<p.home.length;i++){
document.write(p.home[i]+" ");
}
</script>
</body>
</html>
json.html
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>创建一个对象,使用function做为属性值</title>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
</head>
<body>
<script type="text/javascript">
var p = {
id:1,
name:'哈哈',
isLove:true,
home:['广州','深圳'],
show : function(str){
alert("你是" + str);
}
};
//document.write(p.isLove?"已婚":"单身"+"<br/>");
p.show("赵君");
</script>
</body>
</html>