Blogger Information
Blog 19
fans 0
comment 0
visits 5757
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
变量,常量+常用的四种函数类型
vbokok
Original
385 people have browsed it
  1. //1. 数据
  2. //a .常量
  3. let username = 'admin' //声明 赋值
  4. console.log(username) //更新
  5. //b. 变量
  6. const gender = '男' //创建常量时,必须初始化
  7. console.log(gender)
  8. const gender1 = '女'
  9. console.log(gender1)
  10. const xb = '男'
  11. console.log(xb)
  12. //2. 函数
  13. //a .命名函数(先声明,后调用)
  14. function sum1(a, b) {
  15. return 'a + b= ' + (a + b)
  16. }
  17. console.log(sum1(1, 2))
  18. //b. 匿名函数(函数表达式)
  19. let num = function (a, b) {
  20. return `${a} + ${b}= ` + (a + b)
  21. }
  22. console.log(num(4, 5))
  23. //c. 箭头函数(匿名函数的简化)
  24. let num1 = (a, b) => {
  25. return `${a} + ${b}= ` + (a + b)
  26. }
  27. console.log(num1(6, 5))
  28. uname = (a, b) => a + b
  29. console.log(num(7, 5))
  30. //d. 立即执行函数
  31. +((a, b) => console.log(a + b))(100, 101)

Correcting teacher:PHPzPHPz

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