<!DOCTYPE html><html><head><title>01_define.html</title><metahttp-equiv="keywords"content="keyword1,keyword2,keyword3"><metahttp-equiv="description"content="this is my page"><metahttp-equiv="content-type"content="text/html; charset=UTF-8"><!--<link rel="stylesheet" type="text/css" href="./styles.css">--><scripttype="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>