1 <!DOCTYPE html> 2 <html> 3 <head lang="en"> 4 <meta charset="UTF-8"> 5 <title></title> 6 </head> 7 <body> 8 <script> 9 10 //json和对象(对象字面量)的区别仅仅在于,json的key键值对中的键必须带有“”; 11 var json = {"name":"拴住","age":18,"arr":[1,2,3]}; 12 //对象本身没有length,所以不能用for循环遍历 13 console.log(json.length); 14 15 // for(var i=0;i<json.length;i++){ 16 // console.log(json[i]); 17 // } 18 19 20 21 22 </script> 23 </body> 24 </html>