Blogger Information
Blog 34
fans 0
comment 0
visits 20689
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
初探javaScript
小庄
Original
509 people have browsed it

初探javaScript

  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>Document</title>
  8. </head>
  9. <body>
  10. <script>
  11. // 变量 命名规则,遵循驼峰式,或蛇形式
  12. let num = 12; //值类型
  13. // 常量 一般字母全大写
  14. const P = 3.14;
  15. // 数据类型
  16. let str = "Hello"; //字符串
  17. let bool = true; //布尔 (以及Null,Undefined类型)
  18. function printStr(){
  19. console.log("值类型变量num:"+num+"常量P:"+P+"字符串类型str:"+str+"布尔类型bool:"+bool);
  20. }
  21. // 匿名函数
  22. let func = function (){
  23. console.log("值类型变量num:"+num+"常量P:"+P+"字符串类型str:"+str+"布尔类型bool:"+bool);
  24. }
  25. // 箭头函数转化
  26. let funct = () => console.log("值类型变量num:"+num+"常量P:"+P+"字符串类型str:"+str+"布尔类型bool:"+bool);
  27. function returnData(){
  28. return '返回值';
  29. }
  30. function returnData(...arr){
  31. let num = 0;
  32. for(let i = 0; i < arr.length; i ++){
  33. num += arr[i];
  34. }
  35. return num;
  36. }
  37. func();
  38. funct();
  39. returnData();
  40. let arr = [1,2,3,4,5,6]
  41. console.log(returnData(...arr)) //归并,若参数为数组,必须加...,否则无法展开
  42. </script>
  43. </body>
  44. </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