1234567891011121314151617181920212223242526272829303132333435363738394041424344454647 |
- <!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 a = [1,2,3];
- // 解构赋值
- let [w,e,r] = a;
- console.log(w,e,r)
- console.log(w)
- // 2.对象
- var obj = {
- a: 1,
- b: 2,
- c: function() {
- console.log("111")
- }
- }
- obj.c();
- var {a,b,c} = obj;
- console.log(a,b,c)
- // 3.字符串
- let str = 'hello';
- let [z,x,aa,v,bbb] = str;
- console.log(z,x,aa,v,bbb)
- // 4.函数
- function fn1() {
- return {
- name: '孙悟空',
- age: 18
- }
- }
-
- let {name,age} = fn1();
- console.log(name,age)
-
- </script>
- </body>
- </html>
|