1 <!DOCTYPE html>
2 <html>
3 <head>
4 <meta charset="UTF-8">
5 <title></title>
6 </head>
7 <body>
8
9 </body>
10
11 <script type="text/javascript">
12 // js 里面任何事物都可以称为一个对象
13 // var num1 = 5; // num1是一个数字对象
14 // var num2 = new Number(5);
15 // 字符串对象
16 var string1 = "hehe";
17 var string2 = new String("hehe");
18
19
20
21 // 数组也是一个对象(简写的形式可以称为语法糖)
22 var array1 = [];
23 var array2 = new Array;
24 var array3 = new Array(1,2);
25
26
27
28 // 时间对象
29 var nowDate = new Date(); // 当前时间
30 var date = new Date("1999,10,11");
31
32
33
34 // 可以自定义对象
35 var obj1 = new Object;
36 obj1.name = "gxm";
37 obj1.age = 25;
38 console.log(obj1);
39
40
41
42 /*{name:"gxm",age:25}; 在其他语言叫 “字典”*/
43 var obj2 = {name:"gxm",age:25};
44 var student1 = {name:"gxm1",age:25,score:100,sex:"m"};
45 var student2 = {name:"gxm2",age:25,score:100,sex:"m"};
46 var student3 = {name:"gxm3",age:25,score:100,sex:"m"};
47 var student4 = {name:"gxm4",age:25,score:100,sex:"m"};
48 var student5 = {name:"gxm5",age:25,score:100,sex:"m"};
49 var student6 = {name:"gxm6",age:25,score:100,sex:"m"};
50 var name = ["gxm1","gxm2","gxm3","gxm4","gxm5","gxm6"];
51 </script>
52 </html>