Blogger Information
Blog 43
fans 0
comment 0
visits 30358
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
常量、变量与函数
橙絮圆
Original
528 people have browsed it

常量、变量与函数

作业标题:0707作业
作业内容:

  1. 变量,常量,数据类型,实例演示,注意命名规范;
  2. 函数参数与返回值,匿名函数及箭头函数的转化,实例演示;

  • 变量,常量,数据类型,实例演示

    • 代码
    1. <!DOCTYPE html>
    2. <html lang="en">
    3. <head>
    4. <meta charset="UTF-8" />
    5. <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    6. <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    7. <title>常量与变量</title>
    8. </head>
    9. <body>
    10. <!-- 常量 -->
    11. <script>
    12. const TEST = "abcd";
    13. console.log(TEST);
    14. // 变量
    15. let userName = "张老师";
    16. console.log(userName);
    17. //基本数据类型 数值型
    18. let name = 10;
    19. console.log(typeof name);
    20. //字符型
    21. userName = "张老师";
    22. console.log(typeof userName);
    23. //布尔型
    24. let test = true;
    25. console.log(typeof test);
    26. //undefined型
    27. let test1;
    28. console.log(typeof test1);
    29. //null型
    30. let test2 = null;
    31. console.log(typeof test2);
    32. //引入型数据类型
    33. //数组
    34. const test3 = [1, 2, 3, 4, 5];
    35. console.log(typeof test3);
    36. //对象
    37. const test4 = { id: 002, userName: "张三" };
    38. console.log(typeof test4);
    39. //函数
    40. function test5() {
    41. return console("aaa");
    42. }
    43. console.log(typeof test5);
    44. </script>
    45. </body>
    46. </html>

  • 函数参数与返回值,匿名函数及箭头函数的转化

    • 代码

      1. <!DOCTYPE html>
      2. <html lang="en">
      3. <head>
      4. <meta charset="UTF-8" />
      5. <meta http-equiv="X-UA-Compatible" content="IE=edge" />
      6. <meta name="viewport" content="width=device-width, initial-scale=1.0" />
      7. <title>函数参数与返回值,匿名函数及箭头函数的转化,实例演示</title>
      8. </head>
      9. <body>
      10. <script>
      11. // 函数参数与返回值
      12. function student(a, b) {
      13. return a + b;
      14. }
      15. console.log(student(40, 50));
      16. // 匿名函数
      17. let sum = function (a, b) {
      18. return a + b;
      19. };
      20. console.log(sum(30, 50));
      21. //箭头函数
      22. let sum1 = (a, b) => a + b;
      23. console.log(sum1(10, 60));
      24. </script>
      25. </body>
      26. </html>
Correcting teacher:天蓬老师天蓬老师

Correction status:qualified

Teacher's comments:
Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
0 comments
Author's latest blog post