5_rest.html 974 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  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. /* rest 剩余的 */
  12. // function fn(a,b,...rest){
  13. // console.log(a)
  14. // console.log(b)
  15. // console.log(...rest)
  16. // }
  17. // fn(1,2,3,4,5,6,7,8,9)
  18. // function fn1(...rest){
  19. // console.log(rest)
  20. // }
  21. // fn1(1,2,3,4)
  22. // function fn(){
  23. // console.log(arguments)
  24. // /* 取到所有剩余的值 */
  25. // }
  26. // fn(1,2,3,4)
  27. // function fn1(a,b,rest){
  28. // var x = a
  29. // let c = b
  30. // var d = rest
  31. // fn2(d)
  32. // console.log(x + c)
  33. // }
  34. // fn1(1,2,3,4,5,6)
  35. // function fn2(xx){
  36. // // console.log(xx)
  37. // var xx = 30
  38. // }
  39. // 3,报错
  40. // [3,4,5,6] 3
  41. // 报错
  42. </script>
  43. </body>
  44. </html>