1234567891011121314151617181920212223242526272829303132333435363738394041424344 |
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <meta charset="UTF-8">
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
- <title>Document</title>
- </head>
- <body>
- <script>
- // 1.对象的创建
- var obj = {};
- var obj1 = new Object();
- console.log(obj)
- console.log(obj1);
- // 2.对象的属性和方法
- /**
- * obj = {
- * 属性:属性值,
- * ....
- * }
- */
- obj = {
- name:"LiLi",
- age:19
- }
- obj1.name = 'Lucy';
- obj1.age = 20;
- console.log(obj1);
- console.log(obj);
- // 3.对象的访问 对象.属性名 获取对应的属性值
- var a = obj.name;
- console.log(a);
- var b = new Array();
- var c = new Object();
- var x = new Number();
- var y = new String();
- var z = new Boolean();
- console.log(b,c,x,y,z)
- // 避免向其中添加内容 会降低耦合性
- </script>
- </body>
- </html>
|