6_rest.html 618 B

12345678910111213141516171819202122232425262728
  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,b,...rest)
  14. // console.log(a)
  15. // console.log(b)
  16. // console.log(...rest)
  17. // }
  18. // fn(1,2,3,4,5,6,7)
  19. function fn(){
  20. console.log(arguments) /* 取到所有剩余的参数 */
  21. }
  22. fn(1,2,3,4,5)
  23. </script>
  24. </body>
  25. </html>