var book = new Object();
book.title = "javascript : the definitive guide";
book.chapter1 = new Object();
book.chapter1.title = "Introdution to javascript";
book.chapter1.pages = 19;
book.chapter2 = {title:"Loxical Strucutre", page:6};这段代码我想给它归拢到一起,是我下面写的那样吗?var book = {
title:"javascript : the definitive guide",
chapter1:{title:"Introdution to javascript", pages:19},
chapter2:{title:"Loxical Strucutre", page:6}
}; 如果我写的对的话,再请问了,chapter2:{title:"Loxical Strucutre", page:6}中的title是属性名还是属性值?他相对于"Loxical Strucutre"来说是属性名,但是相对于chapter2又是属性值。
book.title = "javascript : the definitive guide";
book.chapter1 = new Object();
book.chapter1.title = "Introdution to javascript";
book.chapter1.pages = 19;
book.chapter2 = {title:"Loxical Strucutre", page:6};这段代码我想给它归拢到一起,是我下面写的那样吗?var book = {
title:"javascript : the definitive guide",
chapter1:{title:"Introdution to javascript", pages:19},
chapter2:{title:"Loxical Strucutre", page:6}
}; 如果我写的对的话,再请问了,chapter2:{title:"Loxical Strucutre", page:6}中的title是属性名还是属性值?他相对于"Loxical Strucutre"来说是属性名,但是相对于chapter2又是属性值。
var book = {
title:"javascript : the definitive guide",
chapter1:{title:"Introdution to javascript", pages:19},
chapter2:{title:"Loxical Strucutre", page:6}
}; 这种叫json对象 其特点就是键值对的形式 其可以嵌套 就是你的chapter1和chapter2的这种
var book = {
title:"javascript : the definitive guide",
chapter1:{title:"Introdution to javascript", pages:19},
chapter2:{title:"Loxical Strucutre", page:6}
}; 这种叫json对象 其特点就是键值对的形式 其可以嵌套 就是你的chapter1和chapter2的这种
//里面的title都是属性名,可以这样理解,冒号前的都是属性名,后面的都是属性值
var book = {
"title": "javascript : the definitive guide",
"chapter1": {
"title": "Introdution to javascript",
"pages": 19
},
"chapter2": {
"title": "Loxical Strucutre",
"page": 6
}
}