Blogger Information
Blog 38
fans 0
comment 0
visits 18869
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
演示常用函数类型、演示常用数据类型
Blackeye
Original
386 people have browsed it

hw

  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>0330作业</title>
  8. </head>
  9. <body>
  10. <script>
  11. // 1.命名函数
  12. function sub(v1, v2){
  13. return v1-v2;
  14. }
  15. console.log(sub(2,1));
  16. // 2.1匿名函数
  17. let subn = function(v1,v2){
  18. return v1-v2;
  19. }
  20. console.log(subn(4,2));
  21. // 2.2立即调用函数()
  22. console.log(
  23. (function(){
  24. return "Hello World.";
  25. })()
  26. )
  27. // 3.箭头函数
  28. let subv = (v1,v2)=>{
  29. return v1-v2;
  30. }
  31. console.log(subv(8,5));
  32. // 3.2 一个参数的箭头函数
  33. let say = name=>{
  34. return "Hello, "+name;
  35. }
  36. console.log(say("Dave"));
  37. // 3.3 没有参数的箭头函数
  38. let email = ()=>{
  39. return "1234@qq.com";
  40. }
  41. console.log(email());
  42. // 3.4 只有一条语句可以不用大括号(默认return)
  43. let phpClass = ()=>"Hello, php.cn";
  44. console.log(phpClass());
  45. // 数据类型
  46. // 1.原始类型:number string boolean undefined null
  47. console.log(typeof 100);
  48. console.log(typeof "Hello");
  49. console.log(typeof true);
  50. let abc;
  51. console.log(typeof abc);
  52. let bcd = null;
  53. console.log(typeof bcd);
  54. // 2.引用类型: array object function
  55. // 引用类型判断不能用typeof, Array.isArray()
  56. let arr = [1,2,3,4]
  57. console.log(arr);
  58. console.log(arr[0]);
  59. let obj = {
  60. id:"1",
  61. option:"2"
  62. }
  63. console.log(obj);
  64. console.log(obj.id);
  65. console.log(obj['id']);
  66. function getName(){
  67. return "Hello, Dave";
  68. }
  69. console.log(getName());
  70. </script>
  71. </body>
  72. </html>
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
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!