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 var obj1 = new Object(); 11 console.log(obj1); 12 13 // var arr = []; 14 //对象的字面量就是一个{};而里面的属性和方法是以:形式对应表现的。(键值对) 15 var obj2 = {aaa:obj1,name:"张三","age":18,sayHi: function () { 16 console.log(1); 17 }}; 18 console.log(obj2); 19 obj2.sayHi(); 20 21 22 23 </script> 24 </body> 25 </html>