Blogger Information
Blog 28
fans 0
comment 0
visits 15719
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
前端作业-JavaSctipt 07-07作业
︷肉園耔︷
Original
499 people have browsed it
  • 命名规则:
    —变量和函数为驼峰式,第一个单词首字母为大写;
    —连接属性下划线为连接
    —不能数字为开头
  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. function getName(name){
  12. return "Welconme to" + name;
  13. }
  14. //调用
  15. console.log(getName('朱老师'));
  16. //重写
  17. function getName(name,city){
  18. return "欢迎来自"+city+"的"+name;
  19. }
  20. console.log(getName("谢老师","都匀"))
  21. console.log(sum(600,800));
  22. function sum(a=4,b){
  23. return a +b;
  24. }
  25. console.log(sum(300));
  26. //归并参数。rest
  27. sum =function (... arr){
  28. // console.log(arr);
  29. // let res =0;
  30. // for(let i=0; i<arr.length;i++){
  31. // res += arr[i];
  32. // }
  33. // return res;
  34. }
  35. let a1 =[1,2,3,4,5,6,7];
  36. //console.log(sum(1,2,3,4,5,6,7));
  37. //console.log(sum(a1));
  38. console.log(sum(...a1));
  39. function getProduct(){
  40. return [123,"手机",654987,"HUAWEI"];
  41. }
  42. let mobile=getProduct();
  43. console.log(mobile);
  44. console.log(mobile[3]);
  45. function getProduct(){
  46. return {id:123,name:"手机","my price":654987,brand:"HUAWEI"};
  47. }
  48. console.log(mobile["my price"]);
  49. sum =(a,b) => {
  50. return a +b;
  51. };
  52. console.log(sum(10,20));
  53. /*
  54. let getName=function(name){
  55. return "hello" +name;
  56. }
  57. */
  58. getName=name =>{
  59. return "Hello3"+ name;
  60. }
  61. console.log(getName("老猪"));
  62. //单一函数 可以省略
  63. sum=(a,b)=>a+b;
  64. console.log(sum(80,50));
  65. //声明
  66. function sun(a,b){
  67. return a+b;
  68. };
  69. //调用
  70. console.log(sum(50,60));
  71. //简化声明 用圆括号包住,使之转为表达式
  72. (function sum(a,b){
  73. console.log(a+b);
  74. })(40,20);
  75. </script>
  76. </body>
  77. </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