<!DOCTYPE html>
<html>
<head>
<title>01_define.html</title>
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="this is my page">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<!--<link rel="stylesheet" type="text/css" href="./styles.css">-->
<script type="text/javascript">
console.log('js中对象的创建之json');
//json就是js对象,但是它会省去xml中的标签,而是通过{}来完成对象的说明
var person = {
name:'lin',
age: 12,
say:function(){
console.log(this.name+'---'+this.age);
} //最后一个属性不加逗号
}
person.say();
//通过json可以创建对象数组,创建方式和js的数组一样
var ps = [
{name:'hurk',age:22},
{name:'lin',age:12}
];
for ( var index in ps) {
console.log(ps[index].name);
}
</script>
</head>
<body>
This is my HTML page. <br>
</body>
</html>
JS 对象之Json
最新推荐文章于 2024-07-22 11:20:51 发布