博客列表 >0708作业 赋值和字面量简化 函数

0708作业 赋值和字面量简化 函数

︷肉園耔︷
︷肉園耔︷原创
2021年07月18日 17:52:06504浏览
  • — 代码区
    ```
    <!DOCTYPE html>
    <html lang="en">
    <head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    </head>
    <body>
    <script>
    /* let x=10;

    1. let y=x;
    2. console.log(x,y);
    3. console.log("x= %d,y=%d" ,x,y);
    4. x=20;
    5. console.log("x=%d,y=%d",x,y);
    6. //2.引用传递
    7. let obj1={
    8. x:10,
    9. y:20,
    10. };
    11. console.log("obj1= %o" ,obj1);
    12. console.table(obj1);
    13. let obj2=obj1;

    console.table(obj2);

    obj1.x=”javascript”;
    console.table(obj1);
    console.table(obj2);

    const f1=x =>(x=10);
    console.log(f1(5));

    1. let username="admin";
    2. let str = `HEllo
    3. ${username}`;
    4. console.log(str);

    let nav=[“首页”,”教学视频”,”文章”];
    let html=`
    <nav>

    1. <a href=""><${nav[0]}></a>
    2. <a href=""><${nav[1]}></a>
    3. <a href=""><${nav[2]}></a>
    4. </nav>

    `
    console.log(html);
    document.body.insertAdjacentHTML(‘beforeend’,html);

  1. let [a,b,c="100"]=[10,29];

console.log(a,b,c);

  1. [a,b,c,...d]=[10,20,30,40,50,60];
  2. console.log(a,b,c,d);
  3. console.log(...d);
  4. let a=10,
  5. b=20,
  6. console.log('a=%d,b=%d'); */
  7. let z=10,
  8. q=20;
  9. console.log(z,q);
  10. [z,q]=[q,z];
  11. console.log(z,q);

//数组传惨
let sum =([a,b]) => a+b;
console.log(sum([10,20]));

  1. /* let sum=([a,b])=> a + b;
  2. console.log(sum(10,20)); */
  3. let lecture={
  4. name:'朱老师',
  5. email:'4986464@qq.com',
  6. getInfo:function(){
  7. return `${this.name}:(${this.email}) `;
  8. }
  9. }
  10. console.log(lecture);
  11. let {name,email} =lecture;
  12. console.log(name,email);
  13. user ={
  14. name,email,
  15. getInfo:()=>'${this.name}:{${this.email}}',
  16. }
  17. console.log(user);
  18. </script>

</body>
</html>
```

声明:本文内容转载自脚本之家,由网友自发贡献,版权归原作者所有,如您发现涉嫌抄袭侵权,请联系admin@php.cn 核实处理。
全部评论
文明上网理性发言,请遵守新闻评论服务协议